diff --git a/__test__/ref-helper.test.ts b/__test__/ref-helper.test.ts index d3b00b7af..5c8d76b87 100644 --- a/__test__/ref-helper.test.ts +++ b/__test__/ref-helper.test.ts @@ -77,6 +77,16 @@ describe('ref-helper tests', () => { expect(checkoutInfo.startPoint).toBeFalsy() }) + it('getCheckoutInfo refs/ without commit', async () => { + const checkoutInfo = await refHelper.getCheckoutInfo( + git, + 'refs/non-standard-ref', + '' + ) + expect(checkoutInfo.ref).toBe('refs/non-standard-ref') + expect(checkoutInfo.startPoint).toBeFalsy() + }) + it('getCheckoutInfo unqualified branch only', async () => { git.branchExists = jest.fn(async (remote: boolean, pattern: string) => { return true diff --git a/dist/index.js b/dist/index.js index 2b7dd09e0..d86415e06 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2005,8 +2005,8 @@ function getCheckoutInfo(git, ref, commit) { result.ref = ref; } // refs/ - else if (upperRef.startsWith('REFS/') && commit) { - result.ref = commit; + else if (upperRef.startsWith('REFS/')) { + result.ref = commit ? commit : ref; } // Unqualified ref, check for a matching branch or tag else { diff --git a/src/ref-helper.ts b/src/ref-helper.ts index 00a1d27c3..58f929098 100644 --- a/src/ref-helper.ts +++ b/src/ref-helper.ts @@ -46,8 +46,8 @@ export async function getCheckoutInfo( result.ref = ref } // refs/ - else if (upperRef.startsWith('REFS/') && commit) { - result.ref = commit + else if (upperRef.startsWith('REFS/')) { + result.ref = commit ? commit : ref } // Unqualified ref, check for a matching branch or tag else {