Skip to content

Commit

Permalink
forgive bad branch name
Browse files Browse the repository at this point in the history
  • Loading branch information
kbr-scylla committed Dec 6, 2024
1 parent 093b61a commit 23fff0f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions git_push_new_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 23fff0f

Please sign in to comment.