Skip to content

Skip redundant PR checkout at head commit#104

Merged
dbpolito merged 2 commits into
mainfrom
fix/skip-pr-checkout-at-head
Jun 24, 2026
Merged

Skip redundant PR checkout at head commit#104
dbpolito merged 2 commits into
mainfrom
fix/skip-pr-checkout-at-head

Conversation

@dbpolito

@dbpolito dbpolito commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

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

  • Skip checkout when already on the PR branch
  • Skip checkout when the current HEAD matches the PR head commit
  • Keep checkout required when neither the branch nor commit matches

Command Coverage

  • Apply the alignment behavior to PR review and fix command output
  • Cover the rendered PR review template expectations

Validation

  • Verify that PR review does not retry checkout when already at the PR head commit
  • Confirm that PR fix still checks out the branch when local state differs from the PR head

- 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
@dbpolito dbpolito self-assigned this Jun 24, 2026
@dbpolito dbpolito added the review trigger kompass review label Jun 24, 2026

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

★★★★☆

Comment thread packages/core/components/align-pr-branch.md Outdated

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

★★★★☆

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.

Comment thread packages/core/components/align-pr-branch.md Outdated
@dbpolito dbpolito merged commit 25b9928 into main Jun 24, 2026
1 check passed
@dbpolito dbpolito deleted the fix/skip-pr-checkout-at-head branch June 24, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review trigger kompass review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant