Skip to content

Commit

Permalink
Only warn about single commit outside of CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday committed Sep 6, 2023
1 parent a5e8204 commit 3cbe8fa
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions node-src/git/getCommitAndBranch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface CommitInfo {
}

export default async function getCommitAndBranch(
{ log },
{ log, options },
{
branchName,
patchBaseRef,
Expand Down Expand Up @@ -50,14 +50,20 @@ export default async function getCommitAndBranch(
CHROMATIC_PULL_REQUEST_SHA,
CHROMATIC_SLUG,
} = process.env;
const { isCi, service, prBranch, branch: ciBranch, commit: ciCommit, slug: ciSlug } = envCi();

const isFromEnvVariable = CHROMATIC_SHA && CHROMATIC_BRANCH; // Our GitHub Action also sets these
const isTravisPrBuild = TRAVIS_EVENT_TYPE === 'pull_request';
const isGitHubAction = GITHUB_ACTIONS === 'true';
const isGitHubPrBuild = GITHUB_EVENT_NAME === 'pull_request';

if (!(await hasPreviousCommit())) {
throw new Error(gitOneCommit(isGitHubAction));
const message = gitOneCommit(isGitHubAction);
if (isCi) {
throw new Error(message);
} else {
log.warn(message);
}
}

if (isFromEnvVariable) {
Expand Down Expand Up @@ -117,7 +123,6 @@ export default async function getCommitAndBranch(
slug = GITHUB_REPOSITORY;
}

const { isCi, service, prBranch, branch: ciBranch, commit: ciCommit, slug: ciSlug } = envCi();
const ciService = process.env.CHROMATIC_ACTION ? 'chromaui/action' : service;
slug = slug || ciSlug;

Expand Down

0 comments on commit 3cbe8fa

Please sign in to comment.