Skip to content

Add exact temporary tag checkout - #8

Merged
andrew merged 2 commits into
mainfrom
checkout-tag
Aug 18, 2026
Merged

Add exact temporary tag checkout#8
andrew merged 2 commits into
mainfrom
checkout-tag

Conversation

@andrew

@andrew andrew commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Add CheckoutTag for 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 ErrTagNotFound so callers can try alternate exact tag names without hiding other repository errors.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 ErrTagNotFound for callers to errors.Is against 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.

Comment thread checkout.go
@andrew andrew self-assigned this Aug 18, 2026
@andrew
andrew merged commit 8b3ccf1 into main Aug 18, 2026
2 checks passed
@andrew
andrew deleted the checkout-tag branch August 18, 2026 11:22
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.

2 participants