Skip to content

feat(gh): use detached review worktrees - #2624

Merged
codeforester merged 3 commits into
mainfrom
enhancement/2623-20261020-feat-gh-use-detached-review-worktrees-and-prune-review-refs
Oct 21, 2026
Merged

codeforester merged 3 commits into
mainfrom
enhancement/2623-20261020-feat-gh-use-detached-review-worktrees-and-prune-review-refs

Conversation

@codeforester

@codeforester codeforester commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add basectl gh review fetch for detached PR-review worktrees backed by refs/base-review/pr/<number>/<slug>.
  • Add basectl gh review prune, dry-run by default, with ownership, cleanliness, detached-state, ref/head, and current PR-state checks before removal.
  • Keep legacy local pr-* refs explicitly out of the permanent workflow; they remain a one-time audited cleanup.

Issue

Fixes #2623

Validation

  • bats cli/bash/commands/basectl/tests/gh-review.bats
  • Full source-checkout BATS suite: 1,067 passed.
  • Full Python suite: 1,828 passed.
  • Stability, command-reference, and documentation-link checks: 25 passed after enrolling the new stable commands.
  • shellcheck cli/bash/commands/basectl/subcommands/gh_review.sh
  • git diff --check

Docs Impact

  • Updated docs/github-workflow.md, docs/command-reference.md, and the basectl command README.
  • Updated Bash/Zsh completions and their parity tests.
  • Updated the stable compatibility fixture for the two new public commands.

@codeforester
codeforester requested a review from a team as a code owner October 20, 2026 13:57
@codeforester

Copy link
Copy Markdown
Collaborator Author

Review finding: mismatched review ref is not cleaned up

base_gh_review_fetch compares the fetched commit with the GitHub API head SHA to protect against a force-push between the API read and git fetch. In the mismatch path, the cleanup used the stale API SHA as the git update-ref -d expected old value, even though the namespaced ref already pointed at the fetched commit. That conditional deletion therefore failed and left an orphaned review ref behind.

Impact: a later fetch for the same PR and slug could report that the review checkout already exists, while gh review prune would retain the orphaned ref for manual cleanup.

This is fixed in 09e52e8f: cleanup now uses the ref's actual fetched SHA, and a regression test verifies that both the detached worktree and namespaced ref are removed when the API SHA is stale.

@codeforester
codeforester merged commit f63551f into main Oct 21, 2026
25 checks passed
@codeforester
codeforester deleted the enhancement/2623-20261020-feat-gh-use-detached-review-worktrees-and-prune-review-refs branch October 21, 2026 14:28
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.

feat(gh): use detached review worktrees and prune review refs

1 participant