Commit 1aec053
authored
🤖 fix: use git show-branch for clearer SSH workspace force delete errors (#530)
## Problem
When attempting to delete SSH workspaces with unpushed commits, the
current error message uses `git log --branches --not --remotes` which
just lists commits without context. This is especially confusing in
squash-merge workflows where feature branch commits never appear in
main, so they always show as "unpushed" even after the PR is merged.
## Solution
Replace the git log command with `git show-branch <current-branch>
origin/<default-branch>` to show the relationship between branches
visually.
**Before:**
```
5d307e9 feat: add feature work 2
5e195dd feat: add feature work 1
```
**After:**
```
Branch status compared to origin/main:
* [feature-branch] feat: add feature work 2
! [origin/main] feat: add all feature work (squashed)
--
* [origin/main] feat: add all feature work (squashed)
+ [feature-branch] feat: add feature work 2
+ [feature-branch^] feat: add feature work 1
+* [origin/main^] Initial commit
Note: If your PR was squash-merged, these commits are already
in origin/main and safe to delete.
```
The `+`, `*`, and `+*` markers clearly show which commits are in which
branch, making it immediately obvious when dealing with a squash-merge
scenario.
## Implementation
- Detects default branch using `git symbolic-ref
refs/remotes/origin/HEAD` with fallbacks to main/master
- Uses `git show-branch` to display branch relationships
- Falls back to original `git log` command when:
- No remote branches exist
- Default branch cannot be determined
- show-branch fails for any reason
This ensures backward compatibility while providing better UX in the
common case.
## Testing
All existing integration tests pass, including the test that validates
error messages contain commit information.
_Generated with `cmux`_1 parent eb177d4 commit 1aec053
1 file changed
+25
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
985 | 985 | | |
986 | 986 | | |
987 | 987 | | |
| 988 | + | |
988 | 989 | | |
989 | 990 | | |
990 | | - | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
991 | 1015 | | |
992 | 1016 | | |
993 | 1017 | | |
| |||
0 commit comments