Skip to content

Commit

Permalink
Add --unreleased-only option
Browse files Browse the repository at this point in the history
Fixes #165
  • Loading branch information
cookpete committed Jun 14, 2020
1 parent b35b4ec commit 0bbab49
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Options:
--starting-version [tag] # specify earliest version to include in changelog
--sort-commits [property] # sort commits by property [relevance, date, date-desc], default: relevance
--release-summary # display tagged commit message body as release summary
--unreleased-only # only output unreleased changes
--handlebars-setup [file] # handlebars setup file
--append-git-log [string] # string to append to git log command
--stdout # output changelog to stdout
Expand Down
8 changes: 6 additions & 2 deletions src/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ function parseReleases (tags, remote, latestVersion, options, onParsed) {
const diff = previousTag ? `${previousTag}..${tag}` : tag
return createRelease(tag, previousTag, date, diff, remote, options, onParsed)
})
if (latestVersion || options.unreleased) {
if (latestVersion || options.unreleased || options.unreleasedOnly) {
const tag = latestVersion || null
const previousTag = tags[0].tag
const date = new Date().toISOString()
const diff = `${previousTag}..`
releases.unshift(createRelease(tag, previousTag, date, diff, remote, options, onParsed))
const unreleased = createRelease(tag, previousTag, date, diff, remote, options, onParsed)
if (options.unreleasedOnly) {
return Promise.all([unreleased])
}
releases.unshift(unreleased)
}
return Promise.all(releases.filter(release => release))
}
Expand Down
1 change: 1 addition & 0 deletions src/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ async function getOptions (argv) {
.option('--starting-version <tag>', 'specify earliest version to include in changelog')
.option('--sort-commits <property>', `sort commits by property [relevance, date, date-desc], default: ${DEFAULT_OPTIONS.sortCommits}`)
.option('--release-summary', 'use tagged commit message body as release summary')
.option('--unreleased-only', 'only output unreleased changes')
.option('--handlebars-setup <file>', 'handlebars setup file')
.option('--append-git-log <string>', 'string to append to git log command')
.option('--stdout', 'output changelog to stdout')
Expand Down

0 comments on commit 0bbab49

Please sign in to comment.