diff --git a/src/actions/createReleaseFromChangelog.js b/src/actions/createReleaseFromChangelog.js index 54514e1..f517ff3 100644 --- a/src/actions/createReleaseFromChangelog.js +++ b/src/actions/createReleaseFromChangelog.js @@ -6,7 +6,18 @@ module.exports = task => async function createReleaseFromChangelog(ref) { if (ref == null) { return; } - const changelog = await task.sideEffect(githubOAuth.getChangelog, {}); + const branch = (() => { + if (ref.startsWith('6.')) { + return '6.x'; + } + if (ref.startsWith('7.')) { + return '7.x'; + } + return 'master'; + })(); + const changelog = await task.sideEffect(githubOAuth.getChangelog, { + branch + }); const lines = changelog.split('\n'); let changelogLines = null; for (let i = 0; i < lines.length; ++i) { diff --git a/src/integrations/githubOAuth.js b/src/integrations/githubOAuth.js index f2db137..6dbb56b 100644 --- a/src/integrations/githubOAuth.js +++ b/src/integrations/githubOAuth.js @@ -47,8 +47,9 @@ module.exports = { return axios.post(`https://github.com/login/oauth/access_token`, body, opts). then(res => res.data); }, - getChangelog() { - const url = host + '/repos/Automattic/mongoose/contents/CHANGELOG.md'; + getChangelog(params) { + const branch = params && params.branch || 'master'; + const url = host + '/repos/Automattic/mongoose/contents/CHANGELOG.md?ref=' + branch; const headers = { accept: 'application/vnd.github.v3.raw' }; diff --git a/test/createReleaseFromChangelog.test.js b/test/createReleaseFromChangelog.test.js index 2407853..76ac1c3 100644 --- a/test/createReleaseFromChangelog.test.js +++ b/test/createReleaseFromChangelog.test.js @@ -31,5 +31,7 @@ describe('createReleaseFromChangelog', function() { const [tagAndName, body] = githubOAuth.createRelease.getCall(0).args; assert.equal(tagAndName, '6.1.1'); assert.equal(body, changelog); + const [{ branch }] = githubOAuth.getChangelog.getCall(0).args; + assert.equal(branch, '6.x'); }); }); \ No newline at end of file