Skip to content

Commit

Permalink
Add tag prefix to compare URLs
Browse files Browse the repository at this point in the history
Fixes #30
  • Loading branch information
cookpete committed Feb 21, 2018
1 parent a66db63 commit 7bc5ada
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export function parseReleases (commits, remote, latestVersion, options) {
if (release.tag || options.unreleased) {
releases.push({
...release,
href: getCompareLink(commit.tag, release.tag || 'HEAD', remote),
href: getCompareLink(
`${options.tagPrefix}${commit.tag}`,
`${options.tagPrefix}${release.tag}` || 'HEAD',
remote
),
commits: release.commits.sort(sortCommits),
major: commit.tag && release.tag && semver.diff(commit.tag, release.tag) === 'major'
})
Expand Down
8 changes: 7 additions & 1 deletion test/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { parseReleases } from '../src/releases'

const options = {
unreleased: false,
commitLimit: 3
commitLimit: 3,
tagPrefix: ''
}

describe('parseReleases', () => {
Expand All @@ -25,6 +26,11 @@ describe('parseReleases', () => {
expect(releases[0].href).to.equal('https://bitbucket.org/user/repo/compare/v1.0.0%0Dv0.1.0')
})

it('includes tag prefix in compare urls', () => {
const releases = parseReleases(commits, remotes.bitbucket, null, { ...options, tagPrefix: 'prefix-' })
expect(releases[0].href).to.equal('https://bitbucket.org/user/repo/compare/prefix-v1.0.0%0Dprefix-v0.1.0')
})

it('supports a version override', () => {
const result = parseReleases(commits, remotes.github, 'v3.0.0', options)
expect(result).to.be.an('array')
Expand Down

0 comments on commit 7bc5ada

Please sign in to comment.