Repository navigation
Check a worktree's commits against its base branch before deleting it - #22
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
@coderabbitai review |
Action not completed
|
|



Fixes DEV-2222.
"Delete worktree" used to ask for confirmation whenever a worktree had commits outside the repo's default branch (local
mainandorigin/main). That made every stacked worktree look risky: a branch created fromfeature-xwhose commits were already merged intofeature-xstill got "N commits not in main or origin/main".What changes
The daemon now finds the worktree's base branch, using only local git:
branch.<b>.remote/merge), when that isoriginor.and names a branch other than its own;branch: Created from <ref>).A candidate is skipped when it is not a valid branch name (
HEAD,HEAD~1, a commit id, …), also names a tag, or exists neither locally nor asorigin/<x>. When neither source gives a usable branch, as for a detached worktree or an expired reflog, the worktree has no base and is compared only with the default branch, as before.Commits now count as at risk only when they are in none of the base's local branch,
origin/<base>, the default branch andorigin/<default>, each counted only when it exists. A commit that reachedmainis therefore never flagged, even when the local base is stale.When commits are at risk and there is an
origin, the daemon fetchesorigin/<default>as before. It also fetchesorigin/<base>when that ref already exists locally. The two fetches run concurrently with--no-write-fetch-head --no-auto-maintenance, so the wait is still bounded by one 20 s limit. Each failed fetch is reported separately.Wire and UI
worktreeAtRisknow carriesbases: string[]andfetchFailed: {ref, reason}[]in place oflocal/remote/ a single nullablefetchFailed. Both protocol versions are raised (daemon 8 → 9, browser 11 → 12), so an upgraded hub restarts older daemons.The confirmation names every base it compared with:
It has 1 commit not in main or origin/main.feature-x):It has 1 commit not in feature-x, origin/feature-x, main or origin/main.It has 1 commit not in feature-x, origin/feature-x as last fetched, main or origin/main as last fetched; couldn't compare with a fresh origin/feature-x because the fetch failed: …; couldn't compare with a fresh origin/main because the fetch failed: ….There is no base branch to check that its commits are merged.The full spec is in
openspec/changes/dev-2222-worktree-term-check-a-worktrees-commits/.Summary by CodeRabbit