checkout icon indicating copy to clipboard operation
checkout copied to clipboard

ref of "HEAD" does not work

Open ljharb opened this issue 1 year ago • 5 comments

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

ljharb avatar Oct 17 '22 20:10 ljharb

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: ''

rainui28 avatar Jan 18 '23 11:01 rainui28

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?

ljharb avatar Nov 02 '23 03:11 ljharb

cc @cory-miller?

ljharb avatar Nov 28 '23 17:11 ljharb

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.

mihaigalos avatar Feb 16 '24 09:02 mihaigalos

cc @jww3?

ljharb avatar Feb 27 '24 04:02 ljharb

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.

AlexAtkinson avatar Apr 04 '24 14:04 AlexAtkinson