From 65c81df3d6b6684d9e33c05bdefc4e0e4ce87609 Mon Sep 17 00:00:00 2001 From: tommasini Date: Fri, 19 Jun 2026 11:59:31 +0100 Subject: [PATCH] every sync into a given release branch reuses the same branch --- .github/scripts/release-branch-sync.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/scripts/release-branch-sync.sh b/.github/scripts/release-branch-sync.sh index d1ebf3b7..aa570d3f 100644 --- a/.github/scripts/release-branch-sync.sh +++ b/.github/scripts/release-branch-sync.sh @@ -176,7 +176,7 @@ If there are conflicts, they will appear in this PR. Resolve them to ensure the } # Process a single release branch -# Returns: 0 = PR created, 1 = failed, 2 = skipped +# Returns: 0 = PR created or refreshed, 1 = failed, 2 = skipped process_release_branch() { local release_branch=$1 local merged_version=$2 @@ -212,12 +212,6 @@ process_release_branch() { # Create sync branch name (replace / with -) local sync_branch="stable-sync-${release_branch//\//-}" - # Check if a sync PR already exists - if pr_exists "$release_branch" "$sync_branch"; then - log_warning "Sync PR already exists for ${release_branch}, skipping" - return 2 - fi - # Check if stable has any new commits compared to the release branch if ! stable_has_new_commits "$release_branch"; then log_success "${release_branch} is already up-to-date with stable, no sync needed" @@ -236,7 +230,8 @@ process_release_branch() { # Create sync branch from stable git checkout -b "$sync_branch" origin/stable - # Push the sync branch (force in case it exists remotely) + # Push the sync branch (force in case it exists remotely). This overwrites the + # remote branch and refreshes any open PR already pointing at it. log_info "Pushing ${sync_branch}..." if git push -u origin "$sync_branch" --force; then log_success "Pushed ${sync_branch}" @@ -245,6 +240,13 @@ process_release_branch() { return 1 fi + # If a sync PR already exists, the force-push above just refreshed it, so we're + # done. Creating a new PR would fail on the duplicate head branch. + if pr_exists "$release_branch" "$sync_branch"; then + log_success "Refreshed existing sync PR for ${release_branch}" + return 0 + fi + # Create the PR (stable-sync branch → release branch) log_info "Creating PR: ${sync_branch} → ${release_branch}" if create_sync_pr "$release_branch" "$sync_branch"; then