Skip to content

fix: batch GitHub PR-state lookups during pruning - #1952

Merged
codeforester merged 1 commit into
mainfrom
bug/1951-20260815-batch-github-pr-state-lookups-during-branch-and-worktree-pru
Aug 16, 2026
Merged

fix: batch GitHub PR-state lookups during pruning#1952
codeforester merged 1 commit into
mainfrom
bug/1951-20260815-batch-github-pr-state-lookups-during-branch-and-worktree-pru

Conversation

@codeforester

Copy link
Copy Markdown
Collaborator

Summary

  • batch all branch PR-state checks into one paginated REST lookup
  • share the result across local branch, remote branch, and worktree pruning
  • retain fail-closed behavior when GitHub lookup fails
  • document the lookup and add regression coverage

Root cause

The prune paths performed one GitHub PR query per branch. That was slow and could exhaust the GitHub GraphQL quota before all branches were classified, leaving stale branch entries behind.

Safety

Branches remain retained when the lookup is unavailable or the PR state is unknown. Closed-but-unmerged branches are deleted only with the explicit --closed-unmerged opt-in; open PR branches remain protected.

Validation

  • bats cli/bash/commands/basectl/tests/gh-branch-worktree.bats — 37 passing
  • bats cli/bash/commands/basectl/tests/gh.bats — 60 passing
  • bash -n cli/bash/commands/basectl/subcommands/gh_branch_worktree.sh
  • shellcheck -e SC2016 cli/bash/commands/basectl/subcommands/gh_branch_worktree.sh
  • git diff --check

Fixes #1951

@codeforester
codeforester marked this pull request as ready for review August 16, 2026 05:22
@codeforester
codeforester requested a review from a team as a code owner August 16, 2026 05:22
@codeforester
codeforester merged commit ed69246 into main Aug 16, 2026
28 checks passed
@codeforester
codeforester deleted the bug/1951-20260815-batch-github-pr-state-lookups-during-branch-and-worktree-pru branch August 16, 2026 05: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.

Batch GitHub PR-state lookups during branch and worktree pruning

1 participant