fix: correct git diff stats logic and add delete worktree confirmation modal#94
Merged
amandal0903 merged 11 commits intomainfrom Apr 9, 2026
Merged
fix: correct git diff stats logic and add delete worktree confirmation modal#94amandal0903 merged 11 commits intomainfrom
amandal0903 merged 11 commits intomainfrom
Conversation
Show a custom modal (matching addWorktreeModal aesthetic) before deleting a worktree. Lists what will be removed (worktree files, branch, session data) and surfaces uncommitted change stats as a warning. Cancel is focused by default so Enter alone cannot trigger deletion.
getDiffStats was using `git branch --show-current` to find the base branch, which returned whatever was checked out locally (e.g. test-branch) rather than the actual default branch (main). This caused diff stats to compare against origin/test-branch — often stale — inflating numbers to +10K lines on branches with no real changes. Now uses `git symbolic-ref refs/remotes/origin/HEAD` to correctly resolve the remote's default branch, falling back to 'main'.
Diff stats now use git merge-base instead of origin/main directly, so numbers reflect only what the branch changed and stay stable when origin/main moves ahead. Delete modal label changed from "uncommitted changes will be lost" to "ahead of <default branch>".
…ests The numstat diff was comparing against the merge-base (fork point) instead of baseRef (current tip of origin/main). This broke squash-merge detection: content already on main via squash merge still showed as diffs because the fork-point predates the branch's changes. Fix: use merge-base only for file discovery and ahead count; use baseRef for the actual numstat so squash-merged content correctly resolves to 0. Also: - Display "ahead of origin/<default_branch>" in delete modal - Add tests for defaultBranch detection (main vs master via origin/HEAD) - Add delete modal test suite (stats text, cancel/delete, ARIA, etc.) - Fix stale comments that described the old broken logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description: