Skip to content

Add opt-in remote-branch deletion with open-PR guard - #29

Merged
seankearon merged 2 commits into
mainfrom
claude/remote-branch-delete-pr-check-4o335g
Jul 28, 2026
Merged

Add opt-in remote-branch deletion with open-PR guard#29
seankearon merged 2 commits into
mainfrom
claude/remote-branch-delete-pr-check-4o335g

Conversation

@seankearon

Copy link
Copy Markdown
Owner

The inline worktree-delete confirm strip now offers an opt-in
"Also delete the remote branch origin/" checkbox, shown only when the
branch exists on origin and unticked by default, so the remote is never touched
unless asked. When the GitHub CLI (gh) reports an open pull request for the
branch, the checkbox is disabled and the strip names the PR with a link to open
it in the browser; the confirmed delete is guarded so origin is left alone while
a PR is open, even if the flag is forced on.

PR detection is a thin wrapper over gh pr list (GitHubCli) mirroring the
existing injectable-runner seam, degrading to "no PR known" whenever gh is
missing, unauthenticated, or the remote isn't GitHub.

  • New: GitHubCli, PullRequestInfo, UrlLauncher
  • WorktreeDeletion carries the open PR (RemoteDeletionBlocked); OpenerService
    queries gh when a remote branch exists
  • MainWindowViewModel + confirm-strip XAML expose the checkbox and PR link
  • Tests: gh parsing/degradation unit tests; E2E for tick-deletes-origin,
    open-PR-blocks-and-links, and option-hidden-when-not-on-origin
  • Docs: Features.md, CHANGELOG.md, README.md

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01Mc2djY95KPQyGwJpqHfy9m

claude added 2 commits July 23, 2026 13:33
The inline worktree-delete confirm strip now offers an opt-in
"Also delete the remote branch origin/<branch>" checkbox, shown only when the
branch exists on origin and unticked by default, so the remote is never touched
unless asked. When the GitHub CLI (gh) reports an open pull request for the
branch, the checkbox is disabled and the strip names the PR with a link to open
it in the browser; the confirmed delete is guarded so origin is left alone while
a PR is open, even if the flag is forced on.

PR detection is a thin wrapper over `gh pr list` (GitHubCli) mirroring the
existing injectable-runner seam, degrading to "no PR known" whenever gh is
missing, unauthenticated, or the remote isn't GitHub.

- New: GitHubCli, PullRequestInfo, UrlLauncher
- WorktreeDeletion carries the open PR (RemoteDeletionBlocked); OpenerService
  queries gh when a remote branch exists
- MainWindowViewModel + confirm-strip XAML expose the checkbox and PR link
- Tests: gh parsing/degradation unit tests; E2E for tick-deletes-origin,
  open-PR-blocks-and-links, and option-hidden-when-not-on-origin
- Docs: Features.md, CHANGELOG.md, README.md

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mc2djY95KPQyGwJpqHfy9m
Adversarial review of the previous commit surfaced robustness and
defense-in-depth gaps around the gh PR check and the remote-delete guard:

- GitHubCli parsing could throw on well-formed-but-wrong-typed gh JSON
  (GetInt32/GetString on unexpected value kinds), which — since gh runs on
  every delete-arm of a pushed branch — would abort the whole delete-arm
  rather than degrade to "no PR". Parsing is now lenient (TryGetInt32 +
  value-kind-checked string reads) with a catch-all backstop, honouring the
  "never throws" contract.
- The gh subprocess had no timeout; a network stall would freeze the
  delete-confirm flow. Bounded with a 10s linked-cancellation timeout that
  degrades to "no PR known".
- The open-PR guard lived only in the view. DeleteBranchesAsync now also
  checks RemoteDeletionBlocked, so the invariant holds at the point git runs
  regardless of caller.
- The success log now leads with a warning (not a green tick) when an
  opted-in remote delete failed.

Tests: gh parsing of unexpected field types and non-integer numbers; a
service-layer test proving an open PR withholds the remote delete even with
WorktreeDeletionChoice.All. Full suite: 175 passing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mc2djY95KPQyGwJpqHfy9m
@seankearon
seankearon merged commit dd07360 into main Jul 28, 2026
2 checks passed
@seankearon
seankearon deleted the claude/remote-branch-delete-pr-check-4o335g branch July 28, 2026 17:39
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.

2 participants