diff --git a/scripts/task.sh b/scripts/task.sh index e03ec77a..6d4b3473 100755 --- a/scripts/task.sh +++ b/scripts/task.sh @@ -126,9 +126,12 @@ cmd_finish() { git merge-base --is-ancestor "$head" "origin/${TARGET_BRANCH}" || die "分支未合入 origin/${TARGET_BRANCH}——先走 PR 合入;放弃则用 --abandon " 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