fix: allow multiple branches with same channel

This commit is contained in:
Pierre Vanduynslager
2019-11-20 16:17:24 -05:00
parent 20e7a38cdb
commit 63f51ae6dd
6 changed files with 138 additions and 6 deletions
+5 -2
View File
@@ -1,6 +1,6 @@
const {isUndefined} = require('lodash');
const semver = require('semver');
const {makeTag} = require('./utils');
const {makeTag, isSameChannel} = require('./utils');
/**
* Last release.
@@ -28,7 +28,10 @@ const {makeTag} = require('./utils');
*/
module.exports = ({branch, options: {tagFormat}}, {before} = {}) => {
const [{version, gitTag, channel} = {}] = branch.tags
.filter(tag => (branch.type === 'prerelease' && branch.channel === tag.channel) || !semver.prerelease(tag.version))
.filter(
tag =>
(branch.type === 'prerelease' && isSameChannel(branch.channel, tag.channel)) || !semver.prerelease(tag.version)
)
.filter(tag => isUndefined(before) || semver.lt(tag.version, before))
.sort((a, b) => semver.rcompare(a.version, b.version));
+2 -1
View File
@@ -1,5 +1,6 @@
const semver = require('semver');
const {FIRST_RELEASE, FIRSTPRERELEASE} = require('./definitions/constants');
const {isSameChannel} = require('./utils');
module.exports = ({branch, nextRelease: {type, channel}, lastRelease, logger}) => {
let version;
@@ -7,7 +8,7 @@ module.exports = ({branch, nextRelease: {type, channel}, lastRelease, logger}) =
const {major, minor, patch} = semver.parse(lastRelease.version);
version =
branch.type === 'prerelease'
? semver.prerelease(lastRelease.version) && lastRelease.channel === channel
? semver.prerelease(lastRelease.version) && isSameChannel(lastRelease.channel, channel)
? semver.inc(lastRelease.version, 'prerelease')
: `${semver.inc(`${major}.${minor}.${patch}`, type)}-${branch.prerelease}.${FIRSTPRERELEASE}`
: semver.inc(lastRelease.version, type);
+5
View File
@@ -71,6 +71,10 @@ function makeTag(tagFormat, version, channel) {
return template(tagFormat)({version: `${version}${channel ? `@${channel}` : ''}`});
}
function isSameChannel(channel, otherChannel) {
return channel === otherChannel || (!channel && !otherChannel);
}
module.exports = {
extractErrors,
hideSensitiveValues,
@@ -86,4 +90,5 @@ module.exports = {
getFirstVersion,
getRange,
makeTag,
isSameChannel,
};