fix: increase next version on prerelease branch based on highest commit type

This commit is contained in:
Pierre Vanduynslager
2019-12-09 22:33:29 -05:00
parent c16fcc9d15
commit 9ecc7a369c
2 changed files with 151 additions and 46 deletions
+133 -38
View File
@@ -11,9 +11,9 @@ test.beforeEach(t => {
test('Increase version for patch release', t => {
t.is(
getNextVersion({
branch: {name: 'master', type: 'release'},
branch: {name: 'master', type: 'release', tags: [{gitTag: 'v1.0.0', version: '1.0.0', channels: [null]}]},
nextRelease: {type: 'patch'},
lastRelease: {version: '1.0.0', channels: [undefined]},
lastRelease: {version: '1.0.0', channels: [null]},
logger: t.context.logger,
}),
'1.0.1'
@@ -23,9 +23,9 @@ test('Increase version for patch release', t => {
test('Increase version for minor release', t => {
t.is(
getNextVersion({
branch: {name: 'master', type: 'release'},
branch: {name: 'master', type: 'release', tags: [{gitTag: 'v1.0.0', version: '1.0.0', channels: [null]}]},
nextRelease: {type: 'minor'},
lastRelease: {version: '1.0.0', channels: [undefined]},
lastRelease: {version: '1.0.0', channels: [null]},
logger: t.context.logger,
}),
'1.1.0'
@@ -35,9 +35,9 @@ test('Increase version for minor release', t => {
test('Increase version for major release', t => {
t.is(
getNextVersion({
branch: {name: 'master', type: 'release'},
branch: {name: 'master', type: 'release', tags: [{gitTag: 'v1.0.0', version: '1.0.0', channels: [null]}]},
nextRelease: {type: 'major'},
lastRelease: {version: '1.0.0', channels: [undefined]},
lastRelease: {version: '1.0.0', channels: [null]},
logger: t.context.logger,
}),
'2.0.0'
@@ -47,7 +47,7 @@ test('Increase version for major release', t => {
test('Return 1.0.0 if there is no previous release', t => {
t.is(
getNextVersion({
branch: {name: 'master', type: 'release'},
branch: {name: 'master', type: 'release', tags: []},
nextRelease: {type: 'minor'},
lastRelease: {},
logger: t.context.logger,
@@ -59,9 +59,14 @@ test('Return 1.0.0 if there is no previous release', t => {
test('Increase version for patch release on prerelease branch', t => {
t.is(
getNextVersion({
branch: {name: 'beta', type: 'prerelease', prerelease: 'beta'},
nextRelease: {type: 'patch'},
lastRelease: {version: '1.0.0', channels: [undefined]},
branch: {
name: 'beta',
type: 'prerelease',
prerelease: 'beta',
tags: [{gitTag: 'v1.0.0', version: '1.0.0', channels: [null]}],
},
nextRelease: {type: 'patch', channel: 'beta'},
lastRelease: {version: '1.0.0', channels: [null]},
logger: t.context.logger,
}),
'1.0.1-beta.1'
@@ -69,31 +74,49 @@ test('Increase version for patch release on prerelease branch', t => {
t.is(
getNextVersion({
branch: {name: 'beta', type: 'prerelease', prerelease: 'beta'},
nextRelease: {type: 'patch'},
lastRelease: {version: '1.0.0-beta.1', channels: [undefined]},
branch: {
name: 'beta',
type: 'prerelease',
prerelease: 'beta',
tags: [
{gitTag: 'v1.0.0', version: '1.0.0', channels: [null]},
{gitTag: 'v1.0.1-beta.1', version: '1.0.1-beta.1', channels: ['beta']},
],
},
nextRelease: {type: 'patch', channel: 'beta'},
lastRelease: {version: '1.0.1-beta.1', channels: ['beta']},
logger: t.context.logger,
}),
'1.0.0-beta.2'
'1.0.1-beta.2'
);
t.is(
getNextVersion({
branch: {name: 'alpha', type: 'prerelease', prerelease: 'alpha'},
branch: {
name: 'alpha',
type: 'prerelease',
prerelease: 'alpha',
tags: [{gitTag: 'v1.0.1-beta.1', version: '1.0.1-beta.1', channels: ['beta']}],
},
nextRelease: {type: 'patch', channel: 'alpha'},
lastRelease: {version: '1.0.0-beta.1', channels: ['beta']},
lastRelease: {version: '1.0.1-beta.1', channels: ['beta']},
logger: t.context.logger,
}),
'1.0.1-alpha.1'
'1.0.2-alpha.1'
);
});
test('Increase version for minor release on prerelease branch', t => {
t.is(
getNextVersion({
branch: {name: 'beta', type: 'prerelease', prerelease: 'beta'},
nextRelease: {type: 'minor'},
lastRelease: {version: '1.0.0', channels: [undefined]},
branch: {
name: 'beta',
type: 'prerelease',
prerelease: 'beta',
tags: [{gitTag: 'v1.0.0', version: '1.0.0', channels: [null]}],
},
nextRelease: {type: 'minor', channel: 'beta'},
lastRelease: {version: '1.0.0', channels: [null]},
logger: t.context.logger,
}),
'1.1.0-beta.1'
@@ -101,31 +124,49 @@ test('Increase version for minor release on prerelease branch', t => {
t.is(
getNextVersion({
branch: {name: 'beta', type: 'prerelease', prerelease: 'beta'},
nextRelease: {type: 'minor'},
lastRelease: {version: '1.0.0-beta.1', channels: [undefined]},
branch: {
name: 'beta',
type: 'prerelease',
prerelease: 'beta',
tags: [
{gitTag: 'v1.0.0', version: '1.0.0', channels: [null]},
{gitTag: 'v1.1.0-beta.1', version: '1.1.0-beta.1', channels: ['beta']},
],
},
nextRelease: {type: 'minor', channel: 'beta'},
lastRelease: {version: '1.1.0-beta.1', channels: ['beta']},
logger: t.context.logger,
}),
'1.0.0-beta.2'
'1.1.0-beta.2'
);
t.is(
getNextVersion({
branch: {name: 'alpha', type: 'prerelease', prerelease: 'alpha'},
branch: {
name: 'alpha',
type: 'prerelease',
prerelease: 'alpha',
tags: [{gitTag: 'v1.1.0-beta.1', version: '1.1.0-beta.1', channels: ['beta']}],
},
nextRelease: {type: 'minor', channel: 'alpha'},
lastRelease: {version: '1.0.0-beta.1', channels: ['beta']},
lastRelease: {version: '1.1.0-beta.1', channels: ['beta']},
logger: t.context.logger,
}),
'1.1.0-alpha.1'
'1.2.0-alpha.1'
);
});
test('Increase version for major release on prerelease branch', t => {
t.is(
getNextVersion({
branch: {name: 'beta', type: 'prerelease', prerelease: 'beta'},
nextRelease: {type: 'major'},
lastRelease: {version: '1.0.0', channels: [undefined]},
branch: {
name: 'beta',
type: 'prerelease',
prerelease: 'beta',
tags: [{gitTag: 'v1.0.0', version: '1.0.0', channels: [null]}],
},
nextRelease: {type: 'major', channel: 'beta'},
lastRelease: {version: '1.0.0', channels: [null]},
logger: t.context.logger,
}),
'2.0.0-beta.1'
@@ -133,29 +174,42 @@ test('Increase version for major release on prerelease branch', t => {
t.is(
getNextVersion({
branch: {name: 'beta', type: 'prerelease', prerelease: 'beta'},
nextRelease: {type: 'major'},
lastRelease: {version: '1.0.0-beta.1', channels: [undefined]},
branch: {
name: 'beta',
type: 'prerelease',
prerelease: 'beta',
tags: [
{gitTag: 'v1.0.0', version: '1.0.0', channels: [null]},
{gitTag: 'v2.0.0-beta.1', version: '2.0.0-beta.1', channels: ['beta']},
],
},
nextRelease: {type: 'major', channel: 'beta'},
lastRelease: {version: '2.0.0-beta.1', channels: ['beta']},
logger: t.context.logger,
}),
'1.0.0-beta.2'
'2.0.0-beta.2'
);
t.is(
getNextVersion({
branch: {name: 'alpha', type: 'prerelease', prerelease: 'alpha'},
branch: {
name: 'alpha',
type: 'prerelease',
prerelease: 'alpha',
tags: [{gitTag: 'v2.0.0-beta.1', version: '2.0.0-beta.1', channels: ['beta']}],
},
nextRelease: {type: 'major', channel: 'alpha'},
lastRelease: {version: '1.0.0-beta.1', channels: ['beta']},
lastRelease: {version: '2.0.0-beta.1', channels: ['beta']},
logger: t.context.logger,
}),
'2.0.0-alpha.1'
'3.0.0-alpha.1'
);
});
test('Return 1.0.0 if there is no previous release on prerelease branch', t => {
t.is(
getNextVersion({
branch: {name: 'beta', type: 'prerelease', prerelease: 'beta'},
branch: {name: 'beta', type: 'prerelease', prerelease: 'beta', tags: []},
nextRelease: {type: 'minor'},
lastRelease: {},
logger: t.context.logger,
@@ -163,3 +217,44 @@ test('Return 1.0.0 if there is no previous release on prerelease branch', t => {
'1.0.0-beta.1'
);
});
test('Increase version for release on prerelease branch after previous commits were merged to release branch', t => {
t.is(
getNextVersion({
branch: {
name: 'beta',
type: 'prerelease',
prerelease: 'beta',
tags: [
{gitTag: 'v1.0.0', version: '1.0.0', channels: [null]},
{gitTag: 'v1.1.0', version: '1.1.0', channels: [null]}, // Version v1.1.0 released on default branch after beta was merged into master
{gitTag: 'v1.1.0-beta.1', version: '1.1.0-beta.1', channels: [null, 'beta']},
],
},
nextRelease: {type: 'minor'},
lastRelease: {version: '1.1.0', channels: [null]},
logger: t.context.logger,
}),
'1.2.0-beta.1'
);
});
test('Increase version for release on prerelease branch based on highest commit type since last regular release', t => {
t.is(
getNextVersion({
branch: {
name: 'beta',
type: 'prerelease',
prerelease: 'beta',
tags: [
{gitTag: 'v1.0.0', version: '1.0.0', channels: [null]},
{gitTag: 'v1.1.0-beta.1', version: '1.1.0-beta.1', channels: [null, 'beta']},
],
},
nextRelease: {type: 'major'},
lastRelease: {version: 'v1.1.0-beta.1', channels: [null]},
logger: t.context.logger,
}),
'2.0.0-beta.1'
);
});