Skip to content

Commit 505942c

Browse files
committed
pull changelog from corresponding branch to generate releases for Mongoose 6.x and 7.x
1 parent 095c14a commit 505942c

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/actions/createReleaseFromChangelog.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@ module.exports = task => async function createReleaseFromChangelog(ref) {
66
if (ref == null) {
77
return;
88
}
9-
const changelog = await task.sideEffect(githubOAuth.getChangelog, {});
9+
const branch = (() => {
10+
if (ref.startsWith('6.')) {
11+
return '6.x';
12+
}
13+
if (ref.startsWith('7.')) {
14+
return '7.x';
15+
}
16+
return 'master';
17+
})();
18+
const changelog = await task.sideEffect(githubOAuth.getChangelog, {
19+
branch
20+
});
1021
const lines = changelog.split('\n');
1122
let changelogLines = null;
1223
for (let i = 0; i < lines.length; ++i) {

src/integrations/githubOAuth.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ module.exports = {
4747
return axios.post(`https://github.com/login/oauth/access_token`, body, opts).
4848
then(res => res.data);
4949
},
50-
getChangelog() {
51-
const url = host + '/repos/Automattic/mongoose/contents/CHANGELOG.md';
50+
getChangelog(params) {
51+
const branch = params && params.branch || 'master';
52+
const url = host + '/repos/Automattic/mongoose/contents/CHANGELOG.md?ref=' + branch;
5253
const headers = {
5354
accept: 'application/vnd.github.v3.raw'
5455
};

test/createReleaseFromChangelog.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ describe('createReleaseFromChangelog', function() {
3131
const [tagAndName, body] = githubOAuth.createRelease.getCall(0).args;
3232
assert.equal(tagAndName, '6.1.1');
3333
assert.equal(body, changelog);
34+
const [{ branch }] = githubOAuth.getChangelog.getCall(0).args;
35+
assert.equal(branch, '6.x');
3436
});
3537
});

0 commit comments

Comments
 (0)