Skip to content

Commit 2aead91

Browse files
committed
Add retry loop for async branch deletion check
GitHub's branch deletion after merge is asynchronous. Add a retry loop to wait for the branch to be deleted before checking if auto-retarget happened.
1 parent d40d6cd commit 2aead91

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

tests/test_e2e.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -564,15 +564,24 @@ echo >&2 "0d. Merging NoAct PR1 (without action installed)..."
564564
merge_pr_with_retry "$NOACT_PR1_URL"
565565
echo >&2 "NoAct PR1 merged. Branch should be auto-deleted and PR2 auto-retargeted."
566566

567-
# Debug: Check if the branch was actually deleted
568-
echo >&2 "Checking if noact_feature1 branch was deleted..."
569-
if gh api "/repos/$REPO_FULL_NAME/branches/noact_feature1" &>/dev/null; then
570-
echo >&2 "❌ Branch noact_feature1 still exists! Auto-delete may not have worked."
567+
# Wait for GitHub to delete the branch (async operation)
568+
echo >&2 "Waiting for noact_feature1 branch to be deleted..."
569+
branch_deleted=false
570+
for attempt in {1..10}; do
571+
if ! gh api "/repos/$REPO_FULL_NAME/branches/noact_feature1" &>/dev/null; then
572+
echo >&2 "✅ Branch noact_feature1 was deleted (attempt $attempt)."
573+
branch_deleted=true
574+
break
575+
fi
576+
echo >&2 "Attempt $attempt/10: Branch still exists, waiting..."
577+
sleep 2
578+
done
579+
580+
if [[ "$branch_deleted" != "true" ]]; then
581+
echo >&2 "❌ Branch noact_feature1 still exists after 10 attempts!"
571582
echo >&2 "Repo settings:"
572583
gh api "/repos/$REPO_FULL_NAME" --jq '{delete_branch_on_merge}' >&2
573584
exit 1
574-
else
575-
echo >&2 "✅ Branch noact_feature1 was deleted."
576585
fi
577586

578587
# Wait for GitHub to auto-retarget PR2 to main

0 commit comments

Comments
 (0)