Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Check out other refs/* by commit if provided, fall back to ref #1924

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions __test__/ref-helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/ref-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down