Fix tag handling: preserve annotations and explicit fetch-tags#2356
Conversation
f12cf15 to
a70240b
Compare
a70240b to
849c4d7
Compare
There was a problem hiding this comment.
Pull request overview
This pull request fixes multiple tag handling issues in the checkout action by changing how tags are fetched and verified.
- Tags are now fetched by reference (not commit hash) to preserve annotations
- The
fetch-tagsoption now properly controls tag fetching via explicit refspecs - Added validation to detect when tags have been moved after workflow trigger (for shallow fetches)
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/ref-helper.ts | Modified getRefSpec to accept fetchTags parameter and fetch tags by ref instead of commit; updated testRef to use ^{commit} for annotated tag dereferencing |
| src/git-source-provider.ts | Removed fetchTags from fetch options (now in refspec); added tag movement validation for shallow fetches |
| src/git-command-manager.ts | Removed fetchTags option from fetch method; always use --no-tags with explicit tag control via refspecs |
| test/ref-helper.test.ts | Added comprehensive tests for new fetchTags parameter behavior |
| test/git-command-manager.test.ts | Updated tests to reflect new fetch behavior with --no-tags always present |
| test/verify-fetch-tags.sh | New script to verify tags are properly fetched in E2E tests |
| .github/workflows/test.yml | Added E2E test for fetch-tags: true functionality |
| dist/index.js | Compiled changes matching source modifications |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR fixes several issues with tag handling in the checkout action: 1. fetch-tags: true now works (fixes #1471) - Tags refspec is now included in getRefSpec() when fetchTags=true - Previously tags were only fetched during a separate fetch that was overwritten by the main fetch 2. Tag checkout preserves annotations (fixes #290) - Tags are fetched via refspec (+refs/tags/*:refs/tags/*) instead of --tags flag - This fetches the actual tag objects, preserving annotations 3. Tag checkout with fetch-tags: true no longer fails (fixes #1467) - When checking out a tag with fetchTags=true, only the wildcard refspec is used (specific tag refspec is redundant) Changes: - src/ref-helper.ts: getRefSpec() now accepts fetchTags parameter and prepends tags refspec when true - src/git-command-manager.ts: fetch() simplified to always use --no-tags, tags are fetched explicitly via refspec - src/git-source-provider.ts: passes fetchTags to getRefSpec() - Added E2E test for fetch-tags option Related #1471, #1467, #290
849c4d7 to
dc12339
Compare
|
@ericsciple This is fixed in v6.0.2 but that is marked as a pre-release. Was that a mistake and, if not, why not mark it as -beta? This is causing action updates tools to skip/flag it, so I wanted to make sure you were aware of that release marker. |
|
@ben-manes thanks! I just now removed the pre-release flag (I had originally planned to remove it sooner). I will watch for issues, then bump the |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [actions/checkout](https://github.com/actions/checkout) | action | patch | `v6.0.1` → `v6.0.2` | --- ### Release Notes <details> <summary>actions/checkout (actions/checkout)</summary> ### [`v6.0.2`](https://github.com/actions/checkout/blob/HEAD/CHANGELOG.md#v602) [Compare Source](actions/checkout@v6.0.1...v6.0.2) - Fix tag handling: preserve annotations and explicit fetch-tags by [@​ericsciple](https://github.com/ericsciple) in [#​2356](actions/checkout#2356) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi44OS4yIiwidXBkYXRlZEluVmVyIjoiNDIuODkuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsidHlwZS9kZXBlbmRlbmNpZXMiXX0=--> Reviewed-on: https://git.tainton.uk/luke/instant-msg-api/pulls/238 Reviewed-by: Luke Tainton <luke@tainton.uk> Co-authored-by: renovate[bot] <renovate-bot@git.tainton.uk> Co-committed-by: renovate[bot] <renovate-bot@git.tainton.uk>
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [actions/checkout](https://github.com/actions/checkout) | action | patch | `v6.0.1` → `v6.0.2` | --- ### Release Notes <details> <summary>actions/checkout (actions/checkout)</summary> ### [`v6.0.2`](https://github.com/actions/checkout/blob/HEAD/CHANGELOG.md#v602) [Compare Source](actions/checkout@v6.0.1...v6.0.2) - Fix tag handling: preserve annotations and explicit fetch-tags by [@​ericsciple](https://github.com/ericsciple) in [#​2356](actions/checkout#2356) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi44OS4yIiwidXBkYXRlZEluVmVyIjoiNDIuODkuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsidHlwZS9kZXBlbmRlbmNpZXMiXX0=--> Reviewed-on: https://git.tainton.uk/actions/gha-workflows/pulls/58 Co-authored-by: renovate[bot] <renovate-bot@git.tainton.uk> Co-committed-by: renovate[bot] <renovate-bot@git.tainton.uk>
Summary
Fixes multiple issues with tag handling in the checkout action.
Issues Fixed
1.
fetch-tags: truedoesn't fetch tags (#1471)Previously, when using
fetch-tags: trueon a branch checkout, tags were not actually fetched. Now tags are properly included in the fetch refspec.2. Annotated tags converted to lightweight (#290)
When checking out an annotated tag, the tag annotation was lost because the action fetched by commit hash rather than by tag reference. Now tags are fetched via explicit refspec (
+refs/tags/*:refs/tags/*), which fetches the actual tag objects and preserves annotations.3. Fatal error with tag +
fetch-tags: true(#1467)Checking out a tag with
fetch-tags: truecaused a fatal error due to duplicate refspecs. Now only the wildcard refspec is used (the specific tag is redundant when fetching all tags).Testing
Unit Tests
Added new unit tests.
E2E Tests