From 61665be9ec7487c303509f19097f588d993ec155 Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Tue, 10 Dec 2019 00:13:45 -0500 Subject: [PATCH] fix: correct log when adding channel to tag --- index.js | 6 +++++- test/index.test.js | 21 ++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 457a907533..2f732a8ae6 100644 --- a/index.js +++ b/index.js @@ -112,7 +112,11 @@ async function run(context, plugins) { await addNote({channels: [...currentRelease.channels, nextRelease.channel]}, nextRelease.gitHead, {cwd, env}); await push(options.repositoryUrl, {cwd, env}); await pushNotes(options.repositoryUrl, {cwd, env}); - logger.success(`Add channel ${nextRelease.channel} to tag ${nextRelease.gitTag}`); + logger.success( + `Add ${nextRelease.channel ? `channel ${nextRelease.channel}` : 'default channel'} to tag ${ + nextRelease.gitTag + }` + ); } context.branch.tags.push({ diff --git a/test/index.test.js b/test/index.test.js index 586b0799eb..67961e6d35 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -785,7 +785,14 @@ async function addChannelMacro(t, mergeFunction) { const publish = stub().resolves(); const success = stub().resolves(); - const config = {branches: [{name: 'master'}, {name: 'next'}], repositoryUrl, tagFormat: `v\${version}`}; + const config = { + branches: [ + {name: 'master', channel: 'latest'}, + {name: 'next', channel: 'next'}, + ], + repositoryUrl, + tagFormat: `v\${version}`, + }; const options = { ...config, verifyConditions, @@ -796,11 +803,11 @@ async function addChannelMacro(t, mergeFunction) { publish, success, }; - const nextRelease2 = { + const nextRelease = { name: 'v2.0.1', type: 'patch', version: '2.0.1', - channel: null, + channel: 'latest', gitTag: 'v2.0.1', gitHead: commits[2].hash, }; @@ -812,13 +819,13 @@ async function addChannelMacro(t, mergeFunction) { const result = await semanticRelease(options, {cwd, env: {}, stdout: {write: () => {}}, stderr: {write: () => {}}}); t.deepEqual(result.releases, [ - {...nextRelease2, ...release1, notes, pluginName: '[Function: functionStub]'}, - {...nextRelease2, notes, pluginName: '[Function: functionStub]'}, + {...nextRelease, ...release1, notes, pluginName: '[Function: functionStub]'}, + {...nextRelease, notes, pluginName: '[Function: functionStub]'}, ]); // Verify the tag has been created on the local and remote repo and reference - t.is(await gitTagHead(nextRelease2.gitTag, {cwd}), nextRelease2.gitHead); - t.is(await gitRemoteTagHead(repositoryUrl, nextRelease2.gitTag, {cwd}), nextRelease2.gitHead); + t.is(await gitTagHead(nextRelease.gitTag, {cwd}), nextRelease.gitHead); + t.is(await gitRemoteTagHead(repositoryUrl, nextRelease.gitTag, {cwd}), nextRelease.gitHead); } addChannelMacro.title = providedTitle => `Add version to a channel after a merge (${providedTitle})`;