You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Abort the run when a git/gh command fails unexpectedly (#52)
`set -e` is suppressed inside `if`/`&&`/`||` conditions and everything they call, including the whole body of `update_direct_target`, which both entry points invoke as a condition. So most failures there fell through silently: a failed `git checkout` let git-merge-onto re-parent the previously checked-out branch (corrupting it, in main's loop over several child PRs), and a failed conflict comment still added the label, leaving a resume with no state marker.
Every `log_cmd` call site now states its failure policy: `run` (log, execute, die on failure; die's explicit `exit` aborts from any context) or `try` (log, execute, hand the status to the caller) for the commands whose failure is an expected outcome. The explicit read-failure aborts from #50 become `die` too, with regression scenarios for both reads. `set -e` stays as a backstop only.
https://claude.ai/code/session_01STkeSJ7cLrmrNn4aTDYkwH
run gh pr edit "$PR_NUMBER" --remove-label "$CONFLICT_LABEL"
276
282
}
277
283
278
284
# Continue processing after user manually resolved conflicts
@@ -297,7 +303,7 @@ continue_after_resolution() {
297
303
# Recover them from the marker the squash-merge run left in the conflict
298
304
# comment.
299
305
local MARKER
300
-
MARKER=$(read_state_marker "$PR_NUMBER")
306
+
MARKER=$(read_state_marker "$PR_NUMBER")|| die "could not read the state marker of PR #$PR_NUMBER"
301
307
if [[ -z"$MARKER" ]];then
302
308
echo"⚠️ No autorestack state marker on $PR_BRANCH; cannot resume safely. Removing the label."
303
309
abandon_resume "$PR_NUMBER""ℹ️ autorestack could not find its state marker on this PR, so it will not update the stack automatically. If this PR still needs its base updated, update its base manually."
# Deleting a PR's base branch closes the PR, so the retargets come first.
398
-
log_cmd git push origin ":$MERGED_BRANCH"
403
+
run git push origin ":$MERGED_BRANCH"
399
404
return 0
400
405
fi
401
406
@@ -407,7 +412,7 @@ main() {
407
412
echo"⚠️ '$MERGED_BRANCH' looks rebase-merged; rebase merges are not supported, leaving the stack alone"
408
413
whileread -r NUMBER BRANCH;do
409
414
[[ -n"$BRANCH" ]] ||continue
410
-
log_cmd gh pr comment "$NUMBER" --body "ℹ️ The base branch \`$MERGED_BRANCH\` of this PR was merged with \"Rebase and merge\", which autorestack does not support. Update this PR manually. \`$MERGED_BRANCH\` was kept so this PR stays open."
415
+
run gh pr comment "$NUMBER" --body "ℹ️ The base branch \`$MERGED_BRANCH\` of this PR was merged with \"Rebase and merge\", which autorestack does not support. Update this PR manually. \`$MERGED_BRANCH\` was kept so this PR stays open."
411
416
done<<(list_child_prs)
412
417
return 0
413
418
fi
@@ -439,17 +444,17 @@ main() {
439
444
# intact on its old base, and the head already contains TARGET_BRANCH when
0 commit comments