Skip to content

Commit c22ae17

Browse files
committedDec 17, 2018
fix: on maintenance branch add to channel only version >= to start range
1 parent 162b4b9 commit c22ae17

File tree

2 files changed

+37
-27
lines changed

2 files changed

+37
-27
lines changed
 

Diff for: ‎lib/get-releases-to-add.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const {uniq} = require('lodash');
22
const semver = require('semver');
33
const semverDiff = require('semver-diff');
44
const getLastRelease = require('./get-last-release');
5-
const {makeTag} = require('./utils');
5+
const {makeTag, getLowerBound} = require('./utils');
66

77
/**
88
* Find releases that have been merged from from a higher branch but not added on the channel of the current branch.
@@ -28,8 +28,14 @@ module.exports = context => {
2828
.reduce(
2929
(releases, higherBranch) => [
3030
...releases,
31-
// For all unique release version of the higher branch merged on current branch
32-
...uniq(branch.tags.filter(({channel}) => channel === higherBranch.channel))
31+
// For all unique release version of the higher branch merged on current branch, excluding lower than start range version for maintenance branches
32+
...uniq(
33+
branch.tags.filter(
34+
({channel, version}) =>
35+
channel === higherBranch.channel &&
36+
(branch.type !== 'maintenance' || semver.gte(version, getLowerBound(branch['merge-range'])))
37+
)
38+
)
3339
// Find ones that are not released on the building branch channel
3440
.filter(tag =>
3541
branch.tags.every(

Diff for: ‎test/get-releases-to-add.test.js

+28-24
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,62 @@
11
import test from 'ava';
22
import getReleasesToAdd from '../lib/get-releases-to-add';
33

4-
test('Return versions merged from release to maintenance branch', t => {
4+
test('Return versions merged from release to maintenance branch, excluding lower than branch start range', t => {
55
const result = getReleasesToAdd({
66
branch: {
7-
name: '1.x',
8-
channel: '1.x',
7+
name: '2.x',
8+
channel: '2.x',
9+
type: 'maintenance',
10+
'merge-range': '>=2.0.0 <3.0.0',
911
tags: [
10-
{gitTag: 'v1.0.0@1.x', version: '1.0.0', channel: '1.x', gitHead: '111'},
11-
{gitTag: 'v1.0.0', version: '1.0.0', gitHead: '111'},
12-
{gitTag: 'v1.1.0', version: '1.1.0', gitHead: '222'},
13-
{gitTag: 'v1.1.1', version: '1.1.1', gitHead: '333'},
12+
{gitTag: 'v2.0.0@2.x', version: '2.0.0', channel: '2.x', gitHead: '111'},
13+
{gitTag: 'v2.0.0', version: '2.0.0', gitHead: '111'},
14+
{gitTag: 'v2.1.0', version: '2.1.0', gitHead: '222'},
15+
{gitTag: 'v2.1.1', version: '2.1.1', gitHead: '333'},
16+
{gitTag: 'v1.0.0', version: '1.0.0', gitHead: '444'},
17+
{gitTag: 'v1.1.0', version: '1.1.0', gitHead: '555'},
1418
],
1519
},
16-
branches: [{name: '1.x', channel: '1.x'}, {name: 'master'}],
20+
branches: [{name: '2.x', channel: '2.x'}, {name: 'master'}],
1721
options: {tagFormat: `v\${version}`},
1822
});
1923

2024
t.deepEqual(result, [
2125
{
22-
lastRelease: {version: '1.0.0', channel: '1.x', gitTag: 'v1.0.0@1.x', name: 'v1.0.0', gitHead: '111'},
26+
lastRelease: {version: '2.0.0', channel: '2.x', gitTag: 'v2.0.0@2.x', name: 'v2.0.0', gitHead: '111'},
2327
currentRelease: {
2428
type: 'minor',
25-
version: '1.1.0',
29+
version: '2.1.0',
2630
channel: undefined,
27-
gitTag: 'v1.1.0',
28-
name: 'v1.1.0',
31+
gitTag: 'v2.1.0',
32+
name: 'v2.1.0',
2933
gitHead: '222',
3034
},
3135
nextRelease: {
3236
type: 'minor',
33-
version: '1.1.0',
34-
channel: '1.x',
35-
gitTag: 'v1.1.0@1.x',
36-
name: 'v1.1.0',
37+
version: '2.1.0',
38+
channel: '2.x',
39+
gitTag: 'v2.1.0@2.x',
40+
name: 'v2.1.0',
3741
gitHead: '222',
3842
},
3943
},
4044
{
41-
lastRelease: {version: '1.1.0', channel: undefined, gitTag: 'v1.1.0', name: 'v1.1.0', gitHead: '222'},
45+
lastRelease: {version: '2.1.0', channel: undefined, gitTag: 'v2.1.0', name: 'v2.1.0', gitHead: '222'},
4246
currentRelease: {
4347
type: 'patch',
44-
version: '1.1.1',
48+
version: '2.1.1',
4549
channel: undefined,
46-
gitTag: 'v1.1.1',
47-
name: 'v1.1.1',
50+
gitTag: 'v2.1.1',
51+
name: 'v2.1.1',
4852
gitHead: '333',
4953
},
5054
nextRelease: {
5155
type: 'patch',
52-
version: '1.1.1',
53-
channel: '1.x',
54-
gitTag: 'v1.1.1@1.x',
55-
name: 'v1.1.1',
56+
version: '2.1.1',
57+
channel: '2.x',
58+
gitTag: 'v2.1.1@2.x',
59+
name: 'v2.1.1',
5660
gitHead: '333',
5761
},
5862
},

0 commit comments

Comments
 (0)
Please sign in to comment.