Teach task-finish to recycle submodule-bearing worktrees #4

Merged
weichen merged 1 commits from fix/task-finish-submodule-recycle into main 2026-09-30 03:27:15 +00:00
+5 -2
View File
@@ -126,9 +126,12 @@ cmd_finish() {
git merge-base --is-ancestor "$head" "origin/${TARGET_BRANCH}" || die "分支未合入 origin/${TARGET_BRANCH}——先走 PR 合入;放弃则用 --abandon <reason>"
echo "[verified] ${branch} 已包含于 origin/${TARGET_BRANCH};成果已落盘"
fi
git -C "$mainrepo" worktree remove "$PWD" && git -C "$mainrepo" branch -d "$branch" 2>/dev/null || git -C "$mainrepo" branch -D "$branch"
git submodule deinit --all -f >/dev/null 2>&1 || true
git -C "$mainrepo" worktree remove "$PWD" 2>/dev/null || { echo "finish: worktree remove 失败(含未清理内容)——已验证合入,可手动 rm -rf 后 git worktree prune" >&2; exit 1; }
git -C "$mainrepo" branch -d "$branch" 2>/dev/null || git -C "$mainrepo" branch -D "$branch"
git -C "$mainrepo" worktree prune
echo "[recycled] worktree 与分支 ${branch} 已回收($(date -u +%FT%TZ))"
git push -q --delete origin "$branch" 2>/dev/null || true
echo "[recycled] worktree 与分支 ${branch} 已回收(本地+远端,$(date -u +%FT%TZ))"
}
case "${1:-}" in