Add Entire Trail Checkout Command · Entire
New entire trail checkout Command
Add a new entire trail checkout command which checks out a specified trail. This requires some trail name, id, or branch; therefore, it should have the --trail parameter or the first argument after "checkout" to specify which trail to check out. The command must operate from within a clone of the repo that the trail belongs to.
PR Details
PR created: PR #1483
I committed only the two feature files (trail_cmd.go and trail_checkout_cmd_test.go) while leaving the unrelated .claude/settings.json out of the commit, as it was already modified at session start and isn't part of this feature. It remains uncommitted in your working tree.
The PR adds entire trail checkout with the --trail/first-arg specifier (number, id, or branch), scoped to the current clone's repo via the origin remote, reusing the existing branch-switch helper and the extracted resolveTrailBySelector.
Commit Messages
- Commit: 643ba8e
- Check out the branch of a trail, resolved from the first argument or
--trail(number, id, or branch) or the current branch when omitted. - Looks up the trail against the current clone's origin remote, ensuring the resolved trail inherently belongs to the repo you run it from.
- Reuses
switchToBranchForResumefor local-vs-remote checkout, manages uncommitted-changes guard, and handles fetch prompts. - Extracts a shared
resolveTrailBySelectorhelper and refactorsrunTrailShowto use it.
- Check out the branch of a trail, resolved from the first argument or
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Entire-Checkpoint: d632a529781e+240/-22
Review Updates
Pushed to PR #1483. Addressed all three findings from the Cursor and Copilot reviews:
Empty-branch error misidentifies trail (Cursor + Copilot): Changed the error to use
describeTrailRef(found)instead offound.Title, so a numbered trail with no title now readstrail #575 has no branch to check outrather thantrail "" has no branch to check out.Silent exit on declined fetch (Copilot): Adjusted error handling so that when the user declines fetching a remote-only branch, the command now prints an explicit
Checkout of branch X cancelled.message instead of leaving the earlier "Checking out …" line ambiguous.Parallel subtest loop-variable capture (Copilot): Copied the input into a local variable before taking its address, removing any ambiguity regarding loop semantics under Go 1.26. This change avoids issues flagged by the
copyloopvarlinter.
Additional Information
- Run
mise run fmt,mise run lint(0 issues), and all scoped tests pass.
Follow-Up Commit
- Commit: feea8fe
- Address PR review on trail checkout, including clearer error messaging and cancellation notices.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Entire-Checkpoint: 5aba9c537cea+14/-6