Add exact temporary tag checkout - #8
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new CheckoutTag helper to temporarily inspect the commit behind an exact local tag (including peeling annotated tags), returning a restore function that attempts to reattach the prior branch when safe. It also exposes ErrTagNotFound so callers can distinguish “tag absent” from other repository errors without implementing Git ref parsing themselves.
Changes:
- Add
CheckoutTag(plus helpers) to validate, resolve, peel, and detach-checkout an exact local tag, and to restore prior HEAD/branch state. - Add
ErrTagNotFoundfor callers toerrors.Isagainst when trying alternate tag spellings. - Add documentation and a comprehensive test suite covering annotated tags, detached-head restore, moved-branch refusal, and context cancellation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| README.md | Documents the new CheckoutTag API with an example and ErrTagNotFound guidance. |
| doc.go | Updates package overview to mention exact temporary tag checkouts. |
| checkout.go | Implements CheckoutTag, ErrTagNotFound, and supporting Git resolution/checkout helpers. |
| checkout_test.go | Adds tests for exact tag resolution, annotated tag peeling, restore behavior, and context handling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
CheckoutTagfor temporarily inspecting an exact local tag without exposing callers to Git ref parsing. It peels annotated tags, checks out a validated commit SHA, and returns a context-aware restore function that preserves attached or detached HEAD state.Expose
ErrTagNotFoundso callers can try alternate exact tag names without hiding other repository errors.