print(f"⚠️ PR#{pr.number} ({head_repo_name}:{head_branch_name} -> {base_repo_name}:{base_branch_name}) is behind {default_branch_name} by {comparison.behind_by} commit(s).")
success = pr.update_branch()
assert success, "Branch update failed"
# Attempt to update the branch
print(f"Merged 'main' into PR#{pr.number} ({pr.head.ref}) successfully.")
try:
success = pr.update_branch()
assert success, "Branch update failed"
print(f"✅ Successfully merged '{default_branch_name}' into PR#{pr.number} ({head_repo_name}:{head_branch_name} -> {base_repo_name}:{base_branch_name}).")
updated_branches += 1
time.sleep(10) # rate limit merges
except Exception as update_error:
print(f"❌ Could not update PR#{pr.number} ({head_repo_name}:{head_branch_name} -> {base_repo_name}:{base_branch_name}): {update_error}")
errors += 1
else:
print(f"✅ PR#{pr.number} ({head_repo_name}:{head_branch_name} -> {base_repo_name}:{base_branch_name}) is already up to date with {default_branch_name}, no merge required.")
up_to_date_branches += 1
except Exception as e:
except Exception as e:
print(f"Could not merge 'main' into PR#{pr.number} ({pr.head.ref}): {e}")