Skip to content

Commit

Permalink
fix: remove confusing logs when searching for releases to add to a ch…
Browse files Browse the repository at this point in the history
…annel
  • Loading branch information
pvdlg committed Dec 17, 2018
1 parent 9a04e64 commit 162b4b9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 28 deletions.
10 changes: 10 additions & 0 deletions index.js
Expand Up @@ -127,6 +127,16 @@ async function run(context, plugins) {

context.lastRelease = await getLastRelease(context);

if (context.lastRelease.gitTag) {
logger.log(
`Found git tag ${context.lastRelease.gitTag} associated with version ${context.lastRelease.version} on branch ${
context.branch.name
}`
);
} else {
logger.log(`No git tag version found on branch ${context.branch.name}`);
}

context.commits = await getCommits(context);

const nextRelease = {
Expand Down
4 changes: 1 addition & 3 deletions lib/get-last-release.js
Expand Up @@ -23,17 +23,15 @@ const {makeTag} = require('./utils');
*
* @return {LastRelease} The last tagged release or empty object if none is found.
*/
module.exports = ({branch: {name, tags, type}, options: {tagFormat}, logger}, {before} = {}) => {
module.exports = ({branch: {tags, type}, options: {tagFormat}}, {before} = {}) => {
const [{version, gitTag, gitHead, channel} = {}] = tags
.filter(tag => type === 'prerelease' || !semver.prerelease(tag.version))
.filter(tag => isUndefined(before) || semver.lt(tag.version, before))
.sort((a, b) => semver.rcompare(a.version, b.version));

if (gitTag) {
logger.log(`Found git tag ${gitTag} associated with version ${version} on branch ${name}`);
return {version, gitTag, gitHead, channel, name: makeTag(tagFormat, version)};
}

logger.log(`No git tag version found on branch ${name}`);
return {};
};
13 changes: 0 additions & 13 deletions test/get-last-release.test.js
@@ -1,13 +1,6 @@
import test from 'ava';
import {stub} from 'sinon';
import getLastRelease from '../lib/get-last-release';

test.beforeEach(t => {
// Stub the logger functions
t.context.log = stub();
t.context.logger = {log: t.context.log};
});

test('Get the highest non-prerelease valid tag', t => {
const result = getLastRelease({
branch: {
Expand All @@ -20,11 +13,9 @@ test('Get the highest non-prerelease valid tag', t => {
type: 'release',
},
options: {tagFormat: `v\${version}`},
logger: t.context.logger,
});

t.deepEqual(result, {version: '2.0.0', gitTag: 'v2.0.0', name: 'v2.0.0', gitHead: '222', channel: undefined});
t.deepEqual(t.context.log.args[0][0], 'Found git tag v2.0.0 associated with version 2.0.0 on branch master');
});

test('Return empty object if no valid tag is found', t => {
Expand All @@ -35,11 +26,9 @@ test('Return empty object if no valid tag is found', t => {
type: 'release',
},
options: {tagFormat: `v\${version}`},
logger: t.context.logger,
});

t.deepEqual(result, {});
t.deepEqual(t.context.log.args[0][0], 'No git tag version found on branch master');
});

test('Get the highest non-prerelease valid tag before a certain version', t => {
Expand All @@ -58,11 +47,9 @@ test('Get the highest non-prerelease valid tag before a certain version', t => {
type: 'release',
},
options: {tagFormat: `v\${version}`},
logger: t.context.logger,
},
{before: '2.1.0'}
);

t.deepEqual(result, {version: '2.0.0', gitTag: 'v2.0.0', name: 'v2.0.0', gitHead: '333', channel: undefined});
t.deepEqual(t.context.log.args[0][0], 'Found git tag v2.0.0 associated with version 2.0.0 on branch master');
});
12 changes: 0 additions & 12 deletions test/get-releases-to-add.test.js
@@ -1,13 +1,6 @@
import test from 'ava';
import {stub} from 'sinon';
import getReleasesToAdd from '../lib/get-releases-to-add';

test.beforeEach(t => {
// Stub the logger functions
t.context.log = stub();
t.context.logger = {log: t.context.log};
});

test('Return versions merged from release to maintenance branch', t => {
const result = getReleasesToAdd({
branch: {
Expand All @@ -22,7 +15,6 @@ test('Return versions merged from release to maintenance branch', t => {
},
branches: [{name: '1.x', channel: '1.x'}, {name: 'master'}],
options: {tagFormat: `v\${version}`},
logger: t.context.logger,
});

t.deepEqual(result, [
Expand Down Expand Up @@ -80,7 +72,6 @@ test('Return versions merged from future branch to release branch', t => {
},
branches: [{name: 'master'}, {name: 'next', channel: 'next'}, {name: 'next-major', channel: 'next-major'}],
options: {tagFormat: `v\${version}`},
logger: t.context.logger,
});

t.deepEqual(result, [
Expand Down Expand Up @@ -138,7 +129,6 @@ test('Return releases sorted by ascending order', t => {
},
branches: [{name: 'master'}, {name: 'next', channel: 'next'}, {name: 'next-major', channel: 'next-major'}],
options: {tagFormat: `v\${version}`},
logger: t.context.logger,
});

t.deepEqual(result, [
Expand Down Expand Up @@ -188,7 +178,6 @@ test('no lastRelease', t => {
branch: {name: 'master', tags: [{gitTag: 'v1.0.0@next', version: '1.0.0', channel: 'next', gitHead: '111'}]},
branches: [{name: 'master'}, {name: 'next', channel: 'next'}],
options: {tagFormat: `v\${version}`},
logger: t.context.logger,
});

t.deepEqual(result, [
Expand Down Expand Up @@ -231,7 +220,6 @@ test('Ignore pre-release versions', t => {
{name: 'alpha', type: 'prerelease', channel: 'alpha'},
],
options: {tagFormat: `v\${version}`},
logger: t.context.logger,
});

t.deepEqual(result, [
Expand Down

0 comments on commit 162b4b9

Please sign in to comment.