Skip to content

Conversation

@ericsciple
Copy link
Contributor

@ericsciple ericsciple commented Jan 8, 2026

Summary

Fixes multiple issues with tag handling in the checkout action.

Issues Fixed

1. fetch-tags: true doesn't fetch tags (#1471)

Previously, when using fetch-tags: true on 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: true caused 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

Scenario Result
Tag + fetch-tags: true ✅ Pass
Tag + fetch-tags: false ✅ Pass
Branch + fetch-tags: true ✅ Pass
Branch + fetch-tags: false ✅ Pass
Shallow clone + tags ✅ Pass
Full clone + tags ✅ Pass
Cross-platform (Ubuntu, Windows, macOS) ✅ Pass
Annotated tag moved after trigger ✅ Fails with clear error
Lightweight tag moved after trigger ✅ Fails with clear error

@ericsciple ericsciple force-pushed the users/erisciple/26-01-tags branch 7 times, most recently from f12cf15 to a70240b Compare January 8, 2026 23:59
@ericsciple ericsciple force-pushed the users/erisciple/26-01-tags branch from a70240b to 849c4d7 Compare January 9, 2026 00:26
@ericsciple ericsciple marked this pull request as ready for review January 9, 2026 00:28
Copilot AI review requested due to automatic review settings January 9, 2026 00:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-tags option 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
@ericsciple ericsciple force-pushed the users/erisciple/26-01-tags branch from 849c4d7 to dc12339 Compare January 9, 2026 01:45
@ericsciple ericsciple merged commit de0fac2 into main Jan 9, 2026
12 checks passed
@ericsciple ericsciple deleted the users/erisciple/26-01-tags branch January 9, 2026 19:42
@ben-manes
Copy link

@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.

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

Successfully merging this pull request may close these issues.

4 participants