diff --git a/docs/_data/global-options.yml b/docs/_data/global-options.yml index fda44437..a52f469e 100644 --- a/docs/_data/global-options.yml +++ b/docs/_data/global-options.yml @@ -42,6 +42,11 @@ valueType: '' description: 'The informations you want to use to build release notes. [issues]' defaultValue: issues +- + short: '-h' + name: head + valueType: '' + description: 'Which branch would you like to include commits from after the last tag?' - short: '-N' name: include-messages diff --git a/lib/_options.js b/lib/_options.js index 49f8d61b..93391001 100644 --- a/lib/_options.js +++ b/lib/_options.js @@ -88,6 +88,12 @@ module.exports = { action: /^(issues|commits|milestones|prs|prs-with-issues)$/i, defaultValue: 'issues' }, + { + short: '-h', + name: 'head', + valueType: '', + description: 'Which branch would you like to include commits from after the last tag?' + }, { short: '-N', name: 'include-messages', diff --git a/lib/src/Gren.js b/lib/src/Gren.js index 487b322b..dd65b437 100644 --- a/lib/src/Gren.js +++ b/lib/src/Gren.js @@ -642,15 +642,10 @@ class Gren { * * @return {string} */ - _generateCommitsBody(commits = [], addEmptyCommit) { + _generateCommitsBody(commits = []) { const bodyMessages = Array.from(commits); - if (bodyMessages.length === 1 || addEmptyCommit) { - bodyMessages.push(null); - } - return bodyMessages - .slice(0, -1) .filter(this._filterCommit.bind(this)) .map(this._templateCommits.bind(this)) .join('\n'); @@ -676,7 +671,7 @@ class Gren { name: this.options.prefix + range[0].name, release: range[0].name, published_at: range[0].date, - body: this._generateCommitsBody(range[2], range[1].id === 0) + '\n' + body: this._generateCommitsBody(range[2]) + '\n' })); loaded(`Commit ranges loaded: ${ranges.length}`); @@ -1047,7 +1042,7 @@ class Gren { if (sortedReleaseDates.length === 1 || this.options.tags.indexOf('all') >= 0) { sortedReleaseDates.push({ id: 0, - date: new Date(0) + date: (new Date(0)).toISOString() }); } @@ -1062,6 +1057,20 @@ class Gren { ]); } + if (this.options.head != null) { + const latest = [{ + ...sortedReleaseDates[0], + name: this.options.head, + date: (new Date()).toISOString() + }, + { + ...sortedReleaseDates[0] + } + ]; + + ranges.unshift(latest); + } + return ranges; } @@ -1101,7 +1110,7 @@ class Gren { if (releaseRange[1].name != null) { ({ data: { commits } } = await this.repo.compareBranches(releaseRange[1].name, releaseRange[0].name)); } else { - ({ data: commits } = await this.repo.listCommits({ until: releaseRange[1].date })); + ({ data: commits } = await this.repo.listCommits({ since: releaseRange[1].date, until: releaseRange[0].date })); } releaseRange.push(commits); }