Skip to content

Commit

Permalink
Fix --starting-version
Browse files Browse the repository at this point in the history
The tags logic was removing the tag after the starting version passed in, so the diff logic became "grab all the commits from the start of the repo to the starting version" – this updates the logic to keep the previous tag to the starting version, so the diff for that version is accurate

Fixes #164
  • Loading branch information
cookpete committed Jun 14, 2020
1 parent 9925190 commit b35b4ec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ async function createRelease (tag, previousTag, date, diff, remote, options, onP

function parseReleases (tags, remote, latestVersion, options, onParsed) {
const releases = tags.map(({ tag, date }, index, tags) => {
if (tags[index - 1] && tags[index - 1].tag === options.startingVersion) {
return null
}
const previousTag = tags[index + 1] ? tags[index + 1].tag : null
const diff = previousTag ? `${previousTag}..${tag}` : tag
return createRelease(tag, previousTag, date, diff, remote, options, onParsed)
Expand All @@ -48,7 +51,7 @@ function parseReleases (tags, remote, latestVersion, options, onParsed) {
const diff = `${previousTag}..`
releases.unshift(createRelease(tag, previousTag, date, diff, remote, options, onParsed))
}
return Promise.all(releases)
return Promise.all(releases.filter(release => release))
}

function getCommitLimit ({ commitLimit, backfillLimit }, emptyRelease, breakingCount) {
Expand Down
3 changes: 2 additions & 1 deletion src/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ async function fetchTags (options) {
if (options.startingVersion) {
const index = tags.findIndex(({ tag }) => tag === options.startingVersion)
if (index !== -1) {
return tags.slice(0, index + 1)
// Leave the tag after the starting version for the diff
return tags.slice(0, index + 2)
}
}
return tags
Expand Down
3 changes: 2 additions & 1 deletion test/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ describe('fetchTags', () => {
it('supports --starting-version', async () => {
expect(await fetchTags({ ...options, startingVersion: 'v0.3.0' })).to.deep.equal([
{ tag: 'v1.0.0', date: '2001-01-01' },
{ tag: 'v0.3.0', date: '2000-04-01' }
{ tag: 'v0.3.0', date: '2000-04-01' },
{ tag: 'v0.2.2', date: '2000-03-03' }
])
})
})
Expand Down

0 comments on commit b35b4ec

Please sign in to comment.