noirbizarre / noirbizarre/git-wipe

Optionally confirm merges against the forge to catch squash-merged branches

Open
#72 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Rust
Stars
5
Forks
0
Avg merge
2d 9m
Merged PRs (30d)
1

Description

Problem

Squash and rebase merges rewrite history, so a merged branch is not an ancestor of the default
branch and git branch --merged never sees it. We compensate at effort 3 with
patch_id_match, squash_patch_id_match and merge_adds_nothing (src/branches.rs:192-266).

Those are good heuristics, but they are heuristics. A squash whose commit was amended, reworded
into a different diff, or merged after a conflict resolution produces no matching patch-id, and the
branch stays behind forever. Meanwhile effort 3 is expensive: several extra git invocations per
branch.

The forge knows the answer exactly, and for the squash case it is the only thing that does.

Proposal

Add an opt-in --check-prs (plus sync.checkprs) that, for branches not already proven merged by
the offline strategies, asks the forge whether their pull request was merged, and tags matches as
merged with a distinct reason (BranchReason::PrMerged in src/report.rs).

  • Implement via the gh CLI (gh pr list --state merged --head <branch> --json headRefName),
    batched into as few calls as possible rather than one per branch.
  • Strictly optional: gh missing, unauthenticated, or offline must produce one warning and fall
    back to the offline strategies — never a failure. This is the same contract as the git >= 2.38
    degradation of merge_adds_nothing.
  • Never on by default: it is networked and it leaks branch names to a remote service.
  • Classify failures through the existing classify_git_stderr / GitErrorKind machinery so
    network and auth errors are distinguished.

Open question worth settling in this issue: whether to shell out to gh at all, or to keep the
tool forge-agnostic and skip this entirely. A gh dependency is a real cost for a tool that
currently needs nothing but git.

Acceptance

  • Squash-merged branch that defeats the patch-id strategies is detected with --check-prs.
  • gh absent / logged out / offline → warning, run completes, offline result unchanged.
  • Off by default; documented as networked and opt-in.
  • pr-merged distinguishable from merged in text and JSON output.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/branches.rs:192-266 and inspect src/report.rs for existing merge strategies and BranchReason values. Review the classify_git_stderr/GitErrorKind machinery before deciding how optional gh calls should degrade. Done means an opt-in --check-prs and sync.checkprs detect qualifying merged PRs, remain off by default, warn and fall back when gh fails, and expose pr-merged in text and JSON.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, github, rust
Domain
cli, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.