pinwheel: Skip worktrees that conflict in wt sync
gt restack stops at a merge conflict mid-rebase, so wt sync left that worktree half rebased. It now aborts the restack with `gt abort --force` (without --force it waits for a confirmation prompt), leaving the worktree as it was, carries on with the rest, and lists the conflicted worktrees apart from those that failed for other reasons. Restacks run with --no-interactive so a prompt cannot stall the loop.
This commit is contained in:
1 parent
9f45ebfb0c
commit
bebeaeb2e1
1 file changed
+16
-4
@@ -10,7 +10,8 @@ wt() {
|
|||||||
' a second branch' \
|
' a second branch' \
|
||||||
" wt rm [<branch>] remove <branch>'s worktree, or the current one; the branch stays" \
|
" wt rm [<branch>] remove <branch>'s worktree, or the current one; the branch stays" \
|
||||||
' wt sync [<args>] gt sync <args> in the primary checkout, then gt restack in every' \
|
' wt sync [<args>] gt sync <args> in the primary checkout, then gt restack in every' \
|
||||||
' worktree not on main whose PR is not merged'
|
' worktree not on main whose PR is not merged; one that conflicts' \
|
||||||
|
' is left as it was and listed at the end'
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ wt() {
|
|||||||
sync)
|
sync)
|
||||||
gt --cwd "$primary" sync "${@:2}" || return
|
gt --cwd "$primary" sync "${@:2}" || return
|
||||||
git -C "$primary" worktree prune
|
git -C "$primary" worktree prune
|
||||||
local line branch merged failed=()
|
local line branch merged failed=() conflicts=()
|
||||||
merged=(${(f)"$(jq -r '.prInfos[] | select(.state == "MERGED") | .headRefName' \
|
merged=(${(f)"$(jq -r '.prInfos[] | select(.state == "MERGED") | .headRefName' \
|
||||||
"$primary/.git/.graphite_pr_info" 2>/dev/null)"})
|
"$primary/.git/.graphite_pr_info" 2>/dev/null)"})
|
||||||
for line in "${(@f)$(git worktree list --porcelain)}"; do
|
for line in "${(@f)$(git worktree list --porcelain)}"; do
|
||||||
@@ -54,15 +55,26 @@ wt() {
|
|||||||
print -r -- "${dir:t}: merged, not restacked"
|
print -r -- "${dir:t}: merged, not restacked"
|
||||||
else
|
else
|
||||||
print -r -- "${dir:t}:"
|
print -r -- "${dir:t}:"
|
||||||
gt --cwd "$dir" restack || failed+=("$dir")
|
if ! gt --cwd "$dir" restack --no-interactive; then
|
||||||
|
if [[ -d $(git -C "$dir" rev-parse --path-format=absolute --git-path rebase-merge) ]]; then
|
||||||
|
gt --cwd "$dir" abort --force --no-interactive >/dev/null
|
||||||
|
print -r -- "wt: aborted, ${dir:t} is left as it was"
|
||||||
|
conflicts+=("$dir")
|
||||||
|
else
|
||||||
|
failed+=("$dir")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
if (( $#conflicts )); then
|
||||||
|
print -u2 -l "wt: merge conflicts, not restacked; run gt restack in:" $conflicts
|
||||||
|
fi
|
||||||
if (( $#failed )); then
|
if (( $#failed )); then
|
||||||
print -u2 -l "wt: gt restack failed in:" $failed
|
print -u2 -l "wt: gt restack failed in:" $failed
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
(( $#conflicts + $#failed == 0 ))
|
||||||
;;
|
;;
|
||||||
-c)
|
-c)
|
||||||
[[ -n $2 ]] || { print -u2 'usage: wt -c <branch>'; return 2 }
|
[[ -n $2 ]] || { print -u2 'usage: wt -c <branch>'; return 2 }
|
||||||
|
|||||||
Reference in new issue
Block a user