Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Signed tags incorrectly checked out #649

Open
danielrbradley opened this issue Dec 8, 2021 · 2 comments
Open

Signed tags incorrectly checked out #649

danielrbradley opened this issue Dec 8, 2021 · 2 comments

Comments

@danielrbradley
Copy link

danielrbradley commented Dec 8, 2021

When pushing a signed tag (or possibly any other tag object), the checked out tag ref points directly to the commit hash rather than the tag object.

Impact: unable to perform additional git commands as tree is out of sync.

Example workflow with issue

  1. Create and push signed tag. Creates something like:

    $ cat .git/refs/tags/v1.0.0
    6d516f7003b7db4f2a6e3a15332f23afa3e4e7f9
    $ git cat-file -t 6d516f7003b7db4f2a6e3a15332f23afa3e4e7f9
    tag
    $ git cat-file -p 6d516f7003b7db4f2a6e3a15332f23afa3e4e7f9
    object 3f7352e5bd0ac4ad07bb64964d96b411a29d769b:refs
    type commit
    tag v1.0.0
    tagger Author Name <author@company.example> 1638969265 +0000
  2. Use checkout action during workflow running based on the tag push trigger:

    "on":
      push:
        tags:
          - v*.*.*
    ...
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2
  3. Source is fetched using a command such as:

    /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +3f7352e5bd0ac4ad07bb64964d96b411a29d769b:refs/tags/v1.0.0
  4. The tag is now out of sync with the remote. If a command tries to sync the tag it will fail e.g.

    $ git fetch --prune --unshallow --tags
    ! [rejected]        v1.0.0     -> v1.0.0  (would clobber existing tag)
    $ cat .git/refs/tags/v1.0.0
    3f7352e5bd0ac4ad07bb64964d96b411a29d769b

Note: this might in fact affect any tag which creates a tag object rather than a direct referent to the commit object.

@joao-conde
Copy link

Was this fixed? Is it available for version 1 of this action?

@dustin-ruetz
Copy link

I encountered this (would clobber existing tag) error today but I was able to work around it by using Git's lightweight tags as opposed to annotated tags. The latter are stored as full objects in the Git database and this is what causes the problem (as @danielrbradley mentioned in the original issue comment).

💡 For future reference in case this helps someone else:

  1. I was working with an initial v0.0.0 placeholder tag that was created as an annotated tag using the git tag -a v0.0.0 -m "initial release" command.
  2. When actions/checkout@v4 failed with the (would clobber existing tag) error, I deleted this annotated tag from both my local repo (git tag -d v0.0.0) and the remote repo (git push origin --delete v0.0.0).
  3. I then re-created the tag as a lightweight tag using the git tag v0.0.0 command.
  4. I pushed the lightweight tag to the remote repo with the git push origin --tags command and confirmed that the git fetch --prune --unshallow --tags command did not error out in the action run ✅

rzr added a commit to rzr/checkout that referenced this issue Feb 13, 2025
Until a proper fix is released,
I believe this will be helpful to to share this trick to community.

Bug: actions#290
Relate-to: actions#1506
Relate-to: actions#649
Origin: https://github.com/actions/checkout/pulls?q=author%3Arzr
Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
rzr added a commit to rzr/checkout that referenced this issue Feb 13, 2025
Until a proper fix is released,
I believe this will be helpful to to share this trick to community.

Bug: actions#290
Relate-to: actions#1506
Relate-to: actions#649
Origin: actions#2081
Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
rzr added a commit to rzr/checkout that referenced this issue Feb 13, 2025
Until a proper fix is released,
I believe this will be helpful to share this trick to community.

Bug: actions#290
Relate-to: actions#1506
Relate-to: actions#649
Origin: actions#2081
Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants