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

do not crash on same SHAs for base and head commits #51

Merged
merged 1 commit into from
Sep 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions packages/client/src/speculativeBranchSelection.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { PrInfo, FileStatuses } from "./api";
import { CodeChecksSettings } from "./types";
import { logger } from "./logger";
import { crash } from "./utils/errors";
import execa = require("execa");

const diffParser = require("./js/diff-parser/diff-parser.js").DiffParser;
Expand All @@ -17,9 +16,8 @@ export async function getPrInfoForSpeculativeBranch(
return;
}
if (baseCommit === headCommit) {
throw crash(
`Speculative branch selection failed. baseCommit can't be equal to headCommit (${baseCommit}). Please create Pull Request to skip this problem.`,
);
// this can happen when someone created a new branch but its still on the same commit as master. we should just treat it as no pr
return;
}

const fileStatuses = await getFileStatuses(gitRepoRootPath, baseCommit, headCommit);
Expand Down Expand Up @@ -51,7 +49,7 @@ async function getBaseCommit(repoPath: string, speculativeBranchesInOrder: strin
logger.debug({ baseBranchName });

if (baseBranchName) {
// @NOTE: this might be CircleCI specific thing but for some reason we NEED to take remote branch origin/* because local one is somehow already updated but this might now work on some environments...
// @NOTE: this might be CircleCI specific thing but for some reason we NEED to take remote branch origin/* because local one is somehow already updated but this might not work on some environments...
try {
await run(repoPath, `git fetch origin ${baseBranchName}`);
const sha = await run(repoPath, `git rev-parse FETCH_HEAD`);
Expand Down