Skip to content

Commit

Permalink
Fix unreleased section sorting
Browse files Browse the repository at this point in the history
Fixes #48
  • Loading branch information
cookpete committed Jun 28, 2018
1 parent 5e8ffe5 commit 00257cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export function parseReleases (commits, remote, latestVersion, options) {

export function sortReleases (a, b) {
if (a.tag && b.tag) return semver.rcompare(a.tag, b.tag)
if (a.tag) return -1
if (b.tag) return 1
if (a.tag) return 1
if (b.tag) return -1
return 0
}

Expand Down
5 changes: 3 additions & 2 deletions test/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ describe('parseReleases', () => {
})

it('sorts releases in the correct order', () => {
const tags = parseReleases(commits, remotes.bitbucket, null, options).map(item => { return item.tag })
expect(tags).to.deep.equal(['v1.0.0', 'v0.1.0', 'v0.0.2', 'v0.0.1'])
const releases = parseReleases(commits, remotes.bitbucket, null, { ...options, unreleased: true })
const tags = releases.map(item => item.tag)
expect(tags).to.deep.equal([null, 'v1.0.0', 'v0.1.0', 'v0.0.2', 'v0.0.1'])
})

it('includes tag prefix in compare urls', () => {
Expand Down

0 comments on commit 00257cd

Please sign in to comment.