Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use correct ci branch context #1521

Merged
merged 6 commits into from Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
Expand Up @@ -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.');
Expand Down
4 changes: 2 additions & 2 deletions test/index.test.js
Expand Up @@ -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, {
Expand Down Expand Up @@ -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(
Expand Down