From 0f0c650b41764d1a3deb33631147c7ca0e39fe59 Mon Sep 17 00:00:00 2001 From: Emmanuel Ogbizi Date: Thu, 25 Jun 2020 12:30:12 -0400 Subject: [PATCH] fix: use correct ci branch context (#1521) --- index.js | 3 ++- test/index.test.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 64288cff22..4d5aaedc73 100644 --- a/index.js +++ b/index.js @@ -26,7 +26,8 @@ marked.setOptions({renderer: new TerminalRenderer()}); /* eslint complexity: off */ async function run(context, plugins) { const {cwd, env, options, logger} = context; - const {isCi, branch: ciBranch, isPr} = context.envCi; + const {isCi, branch, prBranch, isPr} = context.envCi; + const ciBranch = isPr ? prBranch : branch; if (!isCi && !options.dryRun && !options.noCi) { logger.warn('This run was not triggered in a known CI environment, running in dry-run mode.'); diff --git a/test/index.test.js b/test/index.test.js index f32d6fedf5..d2533c4919 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -1258,7 +1258,7 @@ test('Allow local releases with "noCi" option', async (t) => { const semanticRelease = requireNoCache('..', { './lib/get-logger': () => t.context.logger, - 'env-ci': () => ({isCi: false, branch: 'master', isPr: true}), + 'env-ci': () => ({isCi: false, branch: 'master', isPr: false}), }); t.truthy( await semanticRelease(options, { @@ -1357,7 +1357,7 @@ test('Returns false if triggered by a PR', async (t) => { const semanticRelease = requireNoCache('..', { './lib/get-logger': () => t.context.logger, - 'env-ci': () => ({isCi: true, branch: 'master', isPr: true}), + 'env-ci': () => ({isCi: true, branch: 'master', prBranch: 'patch-1', isPr: true}), }); t.false(