Skip to content

Commit

Permalink
fix(create_rc): Prevent failure when we have more than one active rel…
Browse files Browse the repository at this point in the history
…ease branch
  • Loading branch information
chouetz committed Jan 13, 2025
1 parent a55d195 commit f14566c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tasks/libs/common/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def check_base_branch(branch, release_version):
Checks if the given branch is either the default branch or the release branch associated
with the given release version.
"""
return branch == get_default_branch() or branch == release_version.branch()
return branch == get_default_branch() or branch == release_version


def try_git_command(ctx, git_command, non_interactive_retries=2, non_interactive_delay=5):
Expand Down
7 changes: 4 additions & 3 deletions tasks/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,11 @@ def create_rc(ctx, release_branch, patch_version=False, upstream="origin", slack
update_branch = f"release/{new_highest_version}-{int(time.time())}"

check_clean_branch_state(ctx, github, update_branch)
if not check_base_branch(release_branch, new_highest_version):
active_releases = [branch.name for branch in github.latest_unreleased_release_branches()]
if not any(check_base_branch(release_branch, unreleased_branch) for unreleased_branch in active_releases):
raise Exit(
color_message(
f"The branch you are on is neither {get_default_branch()} or the correct release branch ({new_highest_version.branch()}). Aborting.",
f"The branch you are on is neither {get_default_branch()} or amongst the active release branches ({active_releases}). Aborting.",
"red",
),
code=1,
Expand Down Expand Up @@ -514,7 +515,7 @@ def build_rc(ctx, release_branch, patch_version=False, k8s_deployments=False):
print(color_message("Checking repository state", "bold"))

# Check that the base branch is valid
if not check_base_branch(release_branch, new_version):
if not check_base_branch(release_branch, new_version.branch()):
raise Exit(
color_message(
f"The branch you are on is neither {get_default_branch()} or the correct release branch ({new_version.branch()}). Aborting.",
Expand Down

0 comments on commit f14566c

Please sign in to comment.