Skip redundant PR checkout at head commit#104
Conversation
- detect the current HEAD while loading PR context - avoid gh pr checkout when already on the PR branch or head commit - document checkout failure behavior without automatic retries - cover the rendered pr/review workflow with a command template test
There was a problem hiding this comment.
★★★★☆
Clean change — partial and generated outputs stay in sync, the scope guard correctly allows either branch-name or head-commit equality, and the new test pins the pr/review template expectations.
One medium concern: the shared @align-pr-branch partial is used by both pr/review (read-only) and pr/fix (mutating). Case 3 stores <current-head> (a commit SHA) as <active-branch> and skips checkout. That is safe for review, but for pr/fix the later ### Commit And Push Updates step runs a bare git push. If the worktree is in detached HEAD at the PR head commit — or sitting on an unrelated branch that happens to be at that commit — git push is refused under push.default=simple, so <pushed> becomes no and the fixes never reach the PR. The prior behavior always checked out the PR branch by name, which kept push working.
Smallest fix: in the pr/fix template, when <current-branch> differs from <pr-branch> still run gh pr checkout <pr-context.pr.number> even when <current-head> matches the head OID (so commit/push land on the branch), or change the push to git push origin HEAD:<pr-branch> so it works from detached HEAD.
Ticket
SKIPPED
Description
Avoid unnecessary PR checkout attempts when review or fix commands are already on the PR branch or exact head commit, reducing avoidable failures while preserving branch safety checks.
Checklist
PR Branch Alignment
Command Coverage
Validation