Skip to content

Commit

Permalink
fix: look also for previous prerelease versions to determine the next…
Browse files Browse the repository at this point in the history
… one
  • Loading branch information
pvdlg committed Dec 13, 2019
1 parent 61665be commit 9772563
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/get-next-version.js
Expand Up @@ -14,7 +14,9 @@ module.exports = ({branch, nextRelease: {type, channel}, lastRelease, logger}) =
) {
version = highest(
semver.inc(lastRelease.version, 'prerelease'),
`${semver.inc(getLatestVersion(tagsToVersions(branch.tags)), type)}-${branch.prerelease}.${FIRSTPRERELEASE}`
`${semver.inc(getLatestVersion(tagsToVersions(branch.tags), {withPrerelease: true}), type)}-${
branch.prerelease
}.${FIRSTPRERELEASE}`
);
} else {
version = `${semver.inc(`${major}.${minor}.${patch}`, type)}-${branch.prerelease}.${FIRSTPRERELEASE}`;
Expand Down
17 changes: 17 additions & 0 deletions test/get-next-version.test.js
Expand Up @@ -258,3 +258,20 @@ test('Increase version for release on prerelease branch based on highest commit
'2.0.0-beta.1'
);
});

test('Increase version for release on prerelease branch when there is no regular releases on other branches', t => {
t.is(
getNextVersion({
branch: {
name: 'beta',
type: 'prerelease',
prerelease: 'beta',
tags: [{gitTag: 'v1.0.0-beta.1', version: '1.0.0-beta.1', channels: ['beta']}],
},
nextRelease: {type: 'minor', channel: 'beta'},
lastRelease: {version: 'v1.0.0-beta.1', channels: ['beta']},
logger: t.context.logger,
}),
'1.0.0-beta.2'
);
});

0 comments on commit 9772563

Please sign in to comment.