Skip to content

Commit ba14abb

Browse files
author
Simon Engledew
committed
Rewrite the ref to correctly point to refs/remotes
Fixes the rev-parse issues caused by #428
1 parent 972dc3e commit ba14abb

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

lib/actions-util.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions-util.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions-util.test.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions-util.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/actions-util.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test("getRef() returns merge PR ref if GITHUB_REF still checked out but sha has
4040
const sha = "a".repeat(40);
4141

4242
const callback = sinon.stub(actionsutil, "getCommitOid");
43-
callback.withArgs("refs/pull/1/merge").resolves(sha);
43+
callback.withArgs("refs/remotes/pull/1/merge").resolves(sha);
4444
callback.withArgs("HEAD").resolves(sha);
4545

4646
const actualRef = await actionsutil.getRef();

src/actions-util.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,10 @@ export async function getRef(): Promise<string> {
443443
// using GITHUB_REF. There is a subtle race condition where
444444
// git rev-parse GITHUB_REF != GITHUB_SHA, so we must check
445445
// git git-parse GITHUB_REF == git rev-parse HEAD instead.
446-
const hasChangedRef = sha !== head && (await getCommitOid(ref)) !== head;
446+
const hasChangedRef =
447+
sha !== head &&
448+
(await getCommitOid(ref.replace(/^refs\/pull\//, "refs/remotes/pull/"))) !==
449+
head;
447450

448451
if (hasChangedRef) {
449452
const newRef = ref.replace(pull_ref_regex, "refs/pull/$1/head");

0 commit comments

Comments
 (0)