From 23fff0fcca8f458b40e71ae9653e06370d6e5ca6 Mon Sep 17 00:00:00 2001 From: Kamil Braun Date: Fri, 6 Dec 2024 18:36:24 +0100 Subject: [PATCH] forgive bad branch name --- git_push_new_version.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/git_push_new_version.py b/git_push_new_version.py index ed355d021588..c814b3f7a957 100755 --- a/git_push_new_version.py +++ b/git_push_new_version.py @@ -44,12 +44,14 @@ def fetch_pr_data(repo: str, branch: str, token: str, author: str) -> Optional[D def get_new_version_and_branch(old_branch: str) -> tuple[int, str]: match = re.search(r"(.+)-v(\d+)$", old_branch) - if not match: - logging.error(f"Old branch name %s does not follow the pattern branch-vN.", old_branch) - sys.exit(1) + if match: + old_branch_pref = str(match.group(1)) + new_version = int(match.group(2)) + 1 + else: + logging.warning(f"Old branch name %s does not follow the pattern `branch-vN`. Will append `-v2` to new branch name", old_branch) + old_branch_pref = old_branch + new_version = 2 - old_branch_pref = str(match.group(1)) - new_version = int(match.group(2)) + 1 new_branch = f"{old_branch_pref}-v{new_version}" logging.info("New branch name will be: %s", new_branch) return new_version, new_branch