Skip to content

Commit b17fe1e

Browse files
orhantoychrisgavin
andauthored
Handle hidden refs (#1774)
Co-authored-by: Chris Gavin <[email protected]>
1 parent b80ff79 commit b17fe1e

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

__test__/ref-helper.test.ts

+10
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ describe('ref-helper tests', () => {
6767
expect(checkoutInfo.startPoint).toBeFalsy()
6868
})
6969

70+
it('getCheckoutInfo refs/', async () => {
71+
const checkoutInfo = await refHelper.getCheckoutInfo(
72+
git,
73+
'refs/gh/queue/main/pr-123',
74+
commit
75+
)
76+
expect(checkoutInfo.ref).toBe(commit)
77+
expect(checkoutInfo.startPoint).toBeFalsy()
78+
})
79+
7080
it('getCheckoutInfo unqualified branch only', async () => {
7181
git.branchExists = jest.fn(async (remote: boolean, pattern: string) => {
7282
return true

dist/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -2000,9 +2000,13 @@ function getCheckoutInfo(git, ref, commit) {
20002000
result.ref = `refs/remotes/pull/${branch}`;
20012001
}
20022002
// refs/tags/
2003-
else if (upperRef.startsWith('REFS/')) {
2003+
else if (upperRef.startsWith('REFS/TAGS/')) {
20042004
result.ref = ref;
20052005
}
2006+
// refs/
2007+
else if (upperRef.startsWith('REFS/') && commit) {
2008+
result.ref = commit;
2009+
}
20062010
// Unqualified ref, check for a matching branch or tag
20072011
else {
20082012
if (yield git.branchExists(true, `origin/${ref}`)) {

src/ref-helper.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ export async function getCheckoutInfo(
4242
result.ref = `refs/remotes/pull/${branch}`
4343
}
4444
// refs/tags/
45-
else if (upperRef.startsWith('REFS/')) {
45+
else if (upperRef.startsWith('REFS/TAGS/')) {
4646
result.ref = ref
4747
}
48+
// refs/
49+
else if (upperRef.startsWith('REFS/') && commit) {
50+
result.ref = commit
51+
}
4852
// Unqualified ref, check for a matching branch or tag
4953
else {
5054
if (await git.branchExists(true, `origin/${ref}`)) {

0 commit comments

Comments
 (0)