Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b17fe1e

Browse filesBrowse files
orhantoychrisgavin
andauthored
Handle hidden refs (#1774)
Co-authored-by: Chris Gavin <chris@chrisgavin.me>
1 parent b80ff79 commit b17fe1e
Copy full SHA for b17fe1e

File tree

Expand file treeCollapse file tree

3 files changed

+20
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+20
-2
lines changed
Open diff view settings
Collapse file

‎__test__/ref-helper.test.ts‎

Copy file name to clipboardExpand all lines: __test__/ref-helper.test.ts
+10Lines changed: 10 additions & 0 deletions
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
Collapse file

‎dist/index.js‎

Copy file name to clipboardExpand all lines: dist/index.js
+5-1Lines changed: 5 additions & 1 deletion
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}`)) {
Collapse file

‎src/ref-helper.ts‎

Copy file name to clipboardExpand all lines: src/ref-helper.ts
+5-1Lines changed: 5 additions & 1 deletion
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.