diff --git a/lib/workers/pr/changelog/index.js b/lib/workers/pr/changelog/index.js index 61a5d77d11a8327e19c679ad04e06ef9587a965b..4517b9c95aebc74a1b68dfb46e9e7b8968b22cc2 100644 --- a/lib/workers/pr/changelog/index.js +++ b/lib/workers/pr/changelog/index.js @@ -22,7 +22,11 @@ async function getChangeLogJSON(args) { if (!fromVersion || equals(fromVersion, toVersion)) { return null; } - + const cachedResult = await sourceCache.getChangeLogJSON(args); + if (cachedResult) { + logger.debug('Returning cached changelog'); + return cachedResult; + } let token; let endpoint; let gheBaseURL; @@ -42,16 +46,12 @@ async function getChangeLogJSON(args) { } } try { - let res = await sourceCache.getChangeLogJSON(args); - if (!res) { - res = await sourceGithub.getChangeLogJSON({ - ...args, - githubBaseURL, - }); - await sourceCache.setChangeLogJSON(args, res); - } + const res = await sourceGithub.getChangeLogJSON({ + ...args, + githubBaseURL, + }); const output = await addReleaseNotes(res); - + await sourceCache.setChangeLogJSON(args, output); return output; } catch (err) /* istanbul ignore next */ { logger.error( diff --git a/test/workers/pr/__snapshots__/changelog.spec.js.snap b/test/workers/pr/__snapshots__/changelog.spec.js.snap index 67581a19c878f369e10037190059c3d25f425bd6..fd951caaa20866d50401442cf1b663bcfa1321ab 100644 --- a/test/workers/pr/__snapshots__/changelog.spec.js.snap +++ b/test/workers/pr/__snapshots__/changelog.spec.js.snap @@ -163,14 +163,12 @@ Object { Object { "changes": Array [], "compare": Object {}, - "releaseNotes": undefined, "version": "2.5.2", }, Object { "changes": Array [], "compare": Object {}, "date": "2017-12-24T03:20:46.238Z", - "releaseNotes": undefined, "version": "2.4.2", }, Object {