checkout
checkout copied to clipboard
ref of "HEAD" does not work
Related to #910, I'd like to be able to default the ref
to HEAD
so i don't have to hardcode main
or master
or whatever in a reusable workflow, but instead i get:
Determining the checkout info
/usr/bin/git branch --list --remote origin/HEAD
/usr/bin/git tag --list HEAD
Error: A branch or tag with the name 'HEAD' could not be found
Same issue happens when using a commit SHA despite the fact that the README.md specifies
# The branch, tag or SHA to checkout. When checking out the repository that
# triggered a workflow, this defaults to the reference or SHA for that event.
# Otherwise, uses the default branch.
ref: ''
For "HEAD", seems like I'd need to make the changes here: https://github.com/actions/checkout/blob/b4ffde65f46336ab88eb53be808477a3936bae11/src/ref-helper.ts#L33-L60
For the sha, it seems like the logic that handles that is here: https://github.com/actions/checkout/blob/b4ffde65f46336ab88eb53be808477a3936bae11/src/input-helper.ts#L63-L64
cc @ericsciple; would i need to special-case "HEAD" to look up .git/refs/remotes/origin/HEAD
and parse out its ref
value and split out what's after refs/remotes/origin/
? or is there a cleaner/better way to do it?
cc @cory-miller?
Seems the HEAD file doesn't exist in the following hierarchy when using the action:
['./.git/refs/remotes/origin/feat', './.git/refs/remotes/origin/fix', './.git/refs/remotes/origin/main']
I would expect a file called .git/refs/remotes/origin/HEAD
which contains ref: refs/remotes/origin/main
for main.
cc @jww3?
Occasionally I'm reminded of this. Today is one of those occasions. It would be nice if HEAD was included in the GHA environment and showed up when running git show-ref
. There's a great deal of script that references it -- ideally, these assets wouldn't have to be adjusted to run in GHA. Thanks.