Skip to content

Commit 1fd05bf

Browse files
authored
Handle conflicts when updating direct targets (#14)
1 parent e636e95 commit 1fd05bf

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

update-pr-stack.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ update_direct_target() {
6767

6868
if has_squash_commit "$BRANCH" "$TARGET_BRANCH"; then
6969
echo "$BRANCH already up-to-date; skipping"
70-
return
70+
return 0
7171
fi
7272

7373
echo "Updating direct target $BRANCH (from $MERGED_BRANCH to $BASE_BRANCH)"
@@ -109,13 +109,16 @@ update_direct_target() {
109109
# Create the label if it doesn't exist, then add it to the PR
110110
gh label create "$CONFLICT_LABEL" --description "PR needs manual conflict resolution" --color "d73a4a" 2>/dev/null || true
111111
log_cmd gh pr edit "$BRANCH" --add-label "$CONFLICT_LABEL"
112+
return 1
112113
else
113114
log_cmd git merge --no-edit -s ours "$SQUASH_COMMIT"
114115
log_cmd git update-ref MERGE_RESULT "HEAD^{tree}"
115116
COMMIT_MSG="Merge updates from $BASE_BRANCH and squash commit"
116117
CUSTOM_COMMIT=$(log_cmd git commit-tree MERGE_RESULT -p BEFORE_MERGE -p "origin/$MERGED_BRANCH" -p SQUASH_COMMIT -m "$COMMIT_MSG")
117118
log_cmd git reset --hard "$CUSTOM_COMMIT"
118119
fi
120+
121+
return 0
119122
}
120123

121124
update_indirect_target() {
@@ -240,8 +243,11 @@ main() {
240243
INITIAL_TARGETS=($(log_cmd gh pr list --base "$MERGED_BRANCH" --json headRefName --jq '.[].headRefName'))
241244

242245
for BRANCH in "${INITIAL_TARGETS[@]}"; do
243-
update_direct_target "$BRANCH" "$TARGET_BRANCH"
244-
update_branch_recursive "$BRANCH"
246+
if update_direct_target "$BRANCH" "$TARGET_BRANCH"; then
247+
update_branch_recursive "$BRANCH"
248+
else
249+
echo "⚠️ Skipping descendants of $BRANCH until conflicts are resolved"
250+
fi
245251
done
246252

247253
# Update base branches for direct target PRs

0 commit comments

Comments
 (0)