@maxiaochao/pi-toolkit 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/bin/pi-worktree +19 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## 2026-09-11 - v0.5.1
|
|
2
|
+
|
|
3
|
+
- fix pi-worktree: remove now cleans up the branch automatically — merged branches are deleted without prompting, unmerged ones confirm once (one prompt covers both worktree removal and branch deletion), so recreating the same name no longer silently reuses a stale branch
|
|
4
|
+
|
|
1
5
|
## 2026-09-11 - v0.5.0
|
|
2
6
|
|
|
3
7
|
- fix pi-worktree: new worktrees now branch from the current branch instead of a stale origin/main (worktree content no longer misses current work); add start --base <ref> to branch from an explicit ref
|
package/bin/pi-worktree
CHANGED
|
@@ -144,12 +144,31 @@ cmd_remove() {
|
|
|
144
144
|
[[ -d "$dir" ]] || die "worktree not found: $dir"
|
|
145
145
|
# refuse to remove if the branch is not merged into main
|
|
146
146
|
local branch; branch=$(git -C "$dir" branch --show-current)
|
|
147
|
+
local rm_anyway=0
|
|
147
148
|
if [[ -n "$branch" ]] && ! git merge-base --is-ancestor "$branch" main 2>/dev/null; then
|
|
148
149
|
warn "branch '$branch' does not appear merged into 'main' (or no main branch exists)."
|
|
149
150
|
read -rp "Remove anyway? [y/N] " ans
|
|
150
151
|
[[ "$ans" =~ ^[Yy]$ ]] || die "aborted"
|
|
152
|
+
rm_anyway=1
|
|
151
153
|
fi
|
|
152
154
|
git worktree remove "$dir" && ok "removed: $dir"
|
|
155
|
+
# The branch survives `git worktree remove`; recreating the same name would
|
|
156
|
+
# silently reuse this stale branch. Delete merged branches automatically.
|
|
157
|
+
if [[ -n "$branch" ]] && git show-ref --verify --quiet "refs/heads/$branch"; then
|
|
158
|
+
if git branch -d "$branch" 2>/dev/null; then
|
|
159
|
+
ok "deleted merged branch: $branch"
|
|
160
|
+
elif [[ "$rm_anyway" == 1 ]]; then
|
|
161
|
+
git branch -D "$branch" && ok "deleted unmerged branch: $branch (confirmed above)"
|
|
162
|
+
else
|
|
163
|
+
warn "branch '$branch' has unmerged commits."
|
|
164
|
+
read -rp "Delete anyway? [y/N] " ans
|
|
165
|
+
if [[ "$ans" =~ ^[Yy]$ ]]; then
|
|
166
|
+
git branch -D "$branch" && ok "deleted branch: $branch"
|
|
167
|
+
else
|
|
168
|
+
warn "branch '$branch' kept; 'pi-worktree start $branch' will reuse it as-is"
|
|
169
|
+
fi
|
|
170
|
+
fi
|
|
171
|
+
fi
|
|
153
172
|
}
|
|
154
173
|
|
|
155
174
|
cd_wt() {
|
package/package.json
CHANGED