fix: on maintenance branch add to channel only version >= to start range
This commit is contained in:
parent
162b4b9e3b
commit
c22ae17a9b
@ -2,7 +2,7 @@ const {uniq} = require('lodash');
|
|||||||
const semver = require('semver');
|
const semver = require('semver');
|
||||||
const semverDiff = require('semver-diff');
|
const semverDiff = require('semver-diff');
|
||||||
const getLastRelease = require('./get-last-release');
|
const getLastRelease = require('./get-last-release');
|
||||||
const {makeTag} = require('./utils');
|
const {makeTag, getLowerBound} = require('./utils');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find releases that have been merged from from a higher branch but not added on the channel of the current branch.
|
* 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 => {
|
|||||||
.reduce(
|
.reduce(
|
||||||
(releases, higherBranch) => [
|
(releases, higherBranch) => [
|
||||||
...releases,
|
...releases,
|
||||||
// For all unique release version of the higher branch merged on current branch
|
// For all unique release version of the higher branch merged on current branch, excluding lower than start range version for maintenance branches
|
||||||
...uniq(branch.tags.filter(({channel}) => channel === higherBranch.channel))
|
...uniq(
|
||||||
|
branch.tags.filter(
|
||||||
|
({channel, version}) =>
|
||||||
|
channel === higherBranch.channel &&
|
||||||
|
(branch.type !== 'maintenance' || semver.gte(version, getLowerBound(branch['merge-range'])))
|
||||||
|
)
|
||||||
|
)
|
||||||
// Find ones that are not released on the building branch channel
|
// Find ones that are not released on the building branch channel
|
||||||
.filter(tag =>
|
.filter(tag =>
|
||||||
branch.tags.every(
|
branch.tags.every(
|
||||||
|
@ -1,58 +1,62 @@
|
|||||||
import test from 'ava';
|
import test from 'ava';
|
||||||
import getReleasesToAdd from '../lib/get-releases-to-add';
|
import getReleasesToAdd from '../lib/get-releases-to-add';
|
||||||
|
|
||||||
test('Return versions merged from release to maintenance branch', t => {
|
test('Return versions merged from release to maintenance branch, excluding lower than branch start range', t => {
|
||||||
const result = getReleasesToAdd({
|
const result = getReleasesToAdd({
|
||||||
branch: {
|
branch: {
|
||||||
name: '1.x',
|
name: '2.x',
|
||||||
channel: '1.x',
|
channel: '2.x',
|
||||||
|
type: 'maintenance',
|
||||||
|
'merge-range': '>=2.0.0 <3.0.0',
|
||||||
tags: [
|
tags: [
|
||||||
{gitTag: 'v1.0.0@1.x', version: '1.0.0', channel: '1.x', gitHead: '111'},
|
{gitTag: 'v2.0.0@2.x', version: '2.0.0', channel: '2.x', gitHead: '111'},
|
||||||
{gitTag: 'v1.0.0', version: '1.0.0', gitHead: '111'},
|
{gitTag: 'v2.0.0', version: '2.0.0', gitHead: '111'},
|
||||||
{gitTag: 'v1.1.0', version: '1.1.0', gitHead: '222'},
|
{gitTag: 'v2.1.0', version: '2.1.0', gitHead: '222'},
|
||||||
{gitTag: 'v1.1.1', version: '1.1.1', gitHead: '333'},
|
{gitTag: 'v2.1.1', version: '2.1.1', gitHead: '333'},
|
||||||
|
{gitTag: 'v1.0.0', version: '1.0.0', gitHead: '444'},
|
||||||
|
{gitTag: 'v1.1.0', version: '1.1.0', gitHead: '555'},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
branches: [{name: '1.x', channel: '1.x'}, {name: 'master'}],
|
branches: [{name: '2.x', channel: '2.x'}, {name: 'master'}],
|
||||||
options: {tagFormat: `v\${version}`},
|
options: {tagFormat: `v\${version}`},
|
||||||
});
|
});
|
||||||
|
|
||||||
t.deepEqual(result, [
|
t.deepEqual(result, [
|
||||||
{
|
{
|
||||||
lastRelease: {version: '1.0.0', channel: '1.x', gitTag: 'v1.0.0@1.x', name: 'v1.0.0', gitHead: '111'},
|
lastRelease: {version: '2.0.0', channel: '2.x', gitTag: 'v2.0.0@2.x', name: 'v2.0.0', gitHead: '111'},
|
||||||
currentRelease: {
|
currentRelease: {
|
||||||
type: 'minor',
|
type: 'minor',
|
||||||
version: '1.1.0',
|
version: '2.1.0',
|
||||||
channel: undefined,
|
channel: undefined,
|
||||||
gitTag: 'v1.1.0',
|
gitTag: 'v2.1.0',
|
||||||
name: 'v1.1.0',
|
name: 'v2.1.0',
|
||||||
gitHead: '222',
|
gitHead: '222',
|
||||||
},
|
},
|
||||||
nextRelease: {
|
nextRelease: {
|
||||||
type: 'minor',
|
type: 'minor',
|
||||||
version: '1.1.0',
|
version: '2.1.0',
|
||||||
channel: '1.x',
|
channel: '2.x',
|
||||||
gitTag: 'v1.1.0@1.x',
|
gitTag: 'v2.1.0@2.x',
|
||||||
name: 'v1.1.0',
|
name: 'v2.1.0',
|
||||||
gitHead: '222',
|
gitHead: '222',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
lastRelease: {version: '1.1.0', channel: undefined, gitTag: 'v1.1.0', name: 'v1.1.0', gitHead: '222'},
|
lastRelease: {version: '2.1.0', channel: undefined, gitTag: 'v2.1.0', name: 'v2.1.0', gitHead: '222'},
|
||||||
currentRelease: {
|
currentRelease: {
|
||||||
type: 'patch',
|
type: 'patch',
|
||||||
version: '1.1.1',
|
version: '2.1.1',
|
||||||
channel: undefined,
|
channel: undefined,
|
||||||
gitTag: 'v1.1.1',
|
gitTag: 'v2.1.1',
|
||||||
name: 'v1.1.1',
|
name: 'v2.1.1',
|
||||||
gitHead: '333',
|
gitHead: '333',
|
||||||
},
|
},
|
||||||
nextRelease: {
|
nextRelease: {
|
||||||
type: 'patch',
|
type: 'patch',
|
||||||
version: '1.1.1',
|
version: '2.1.1',
|
||||||
channel: '1.x',
|
channel: '2.x',
|
||||||
gitTag: 'v1.1.1@1.x',
|
gitTag: 'v2.1.1@2.x',
|
||||||
name: 'v1.1.1',
|
name: 'v2.1.1',
|
||||||
gitHead: '333',
|
gitHead: '333',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user