Skip to content

Commit

Permalink
maybe all of this is unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMcCulloh committed Aug 29, 2023
1 parent 748378d commit 88ea712
Showing 1 changed file with 1 addition and 35 deletions.
36 changes: 1 addition & 35 deletions tools/bump-pack/src/derive-shas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,41 +65,7 @@ async function findSuccessfulCommit(branchName: string) {
let eventName = process.env.GITHUB_EVENT_NAME ?? context.eventName;

if (eventName === "pull_request") {
const actualPRHeadSha =
process.env.GITHUB_PR_HEAD ?? context.payload?.pull_request?.head?.sha;

try {
// create a new branch locally to rebase onto main
const tmpBranchName = `tmp-pr-diff-${HEAD_SHA}`;

try {
betterExec(`git branch -D --force ${tmpBranchName}`);
} catch {}
betterExec(`git switch -c ${baseBranchName}`);
betterExec(`git switch -c ${branchName}`);
betterExec(`git reset --hard ${actualPRHeadSha}`);

betterExec(`git switch -C ${tmpBranchName} ${actualPRHeadSha}`);
betterExec(
`git rebase --onto ${baseBranchName} ${branchName} ${tmpBranchName}`
);

HEAD_SHA = tmpBranchName;
return baseBranchName;
} catch (err) {
console.log(`Failed to rebase onto ${baseBranchName}`);
console.log(err);

return undefined;
} finally {
// switch back to what we were on before
try {
betterExec(`git rebase --quit`);
} catch {}

// regardless of whether we succeeded or not, switch back to the original commit
betterExec(`git reset --hard ${originalHEAD_SHA}`);
}
return baseBranchName;
}

const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
Expand Down

0 comments on commit 88ea712

Please sign in to comment.