Skip to content

Commit 73ba41a

Browse files
committed
Add option to get commits since last tag; don't skip any commits
1 parent 59f222a commit 73ba41a

3 files changed

Lines changed: 29 additions & 9 deletions

File tree

docs/_data/global-options.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
valueType: '<issues|commits|milestones|prs|prs-with-issues>'
4343
description: 'The informations you want to use to build release notes. [issues]'
4444
defaultValue: issues
45+
-
46+
short: '-h'
47+
name: head
48+
valueType: '<string>'
49+
description: 'Which branch would you like to include commits from after the last tag?'
4550
-
4651
short: '-N'
4752
name: include-messages

lib/_options.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ module.exports = {
8888
action: /^(issues|commits|milestones|prs|prs-with-issues)$/i,
8989
defaultValue: 'issues'
9090
},
91+
{
92+
short: '-h',
93+
name: 'head',
94+
valueType: '<string>',
95+
description: 'Which branch would you like to include commits from after the last tag?'
96+
},
9197
{
9298
short: '-N',
9399
name: 'include-messages',

lib/src/Gren.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -642,15 +642,10 @@ class Gren {
642642
*
643643
* @return {string}
644644
*/
645-
_generateCommitsBody(commits = [], addEmptyCommit) {
645+
_generateCommitsBody(commits = []) {
646646
const bodyMessages = Array.from(commits);
647647

648-
if (bodyMessages.length === 1 || addEmptyCommit) {
649-
bodyMessages.push(null);
650-
}
651-
652648
return bodyMessages
653-
.slice(0, -1)
654649
.filter(this._filterCommit.bind(this))
655650
.map(this._templateCommits.bind(this))
656651
.join('\n');
@@ -676,7 +671,7 @@ class Gren {
676671
name: this.options.prefix + range[0].name,
677672
release: range[0].name,
678673
published_at: range[0].date,
679-
body: this._generateCommitsBody(range[2], range[1].id === 0) + '\n'
674+
body: this._generateCommitsBody(range[2]) + '\n'
680675
}));
681676

682677
loaded(`Commit ranges loaded: ${ranges.length}`);
@@ -1047,7 +1042,7 @@ class Gren {
10471042
if (sortedReleaseDates.length === 1 || this.options.tags.indexOf('all') >= 0) {
10481043
sortedReleaseDates.push({
10491044
id: 0,
1050-
date: new Date(0)
1045+
date: (new Date(0)).toISOString()
10511046
});
10521047
}
10531048

@@ -1062,6 +1057,20 @@ class Gren {
10621057
]);
10631058
}
10641059

1060+
if (this.options.head != null) {
1061+
const latest = [{
1062+
...sortedReleaseDates[0],
1063+
name: this.options.head,
1064+
date: (new Date()).toISOString()
1065+
},
1066+
{
1067+
...sortedReleaseDates[0]
1068+
}
1069+
];
1070+
1071+
ranges.unshift(latest);
1072+
}
1073+
10651074
return ranges;
10661075
}
10671076

@@ -1101,7 +1110,7 @@ class Gren {
11011110
if (releaseRange[1].name != null) {
11021111
({ data: { commits } } = await this.repo.compareBranches(releaseRange[1].name, releaseRange[0].name));
11031112
} else {
1104-
({ data: commits } = await this.repo.listCommits({ until: releaseRange[1].date }));
1113+
({ data: commits } = await this.repo.listCommits({ since: releaseRange[1].date, until: releaseRange[0].date }));
11051114
}
11061115
releaseRange.push(commits);
11071116
}

0 commit comments

Comments
 (0)