-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import re | ||
|
||
|
||
def format_branch_name(name): | ||
# If branch has name like "bugfix/issue-1234-bug-title", take only "1234" part | ||
pattern = re.compile("^(bugfix|feature)\/issue-(?P<branch>[0-9]+)-\S+") | ||
|
||
match = pattern.search(name) | ||
if match: | ||
return match.group("branch") | ||
|
||
# function is called even if branch name is not used in a current template | ||
# just left properly named branches intact | ||
if name in ["master", "dev", "main"]: | ||
return name | ||
|
||
# fail in case of wrong branch names like "bugfix/issue-unknown" | ||
raise ValueError(f"Wrong branch name: {name}") | ||
|
||
|
||
def format_tag_name(name): | ||
# If tag has name like "release/1.2.3", take only "1.2.3" part | ||
pattern = re.compile(r"release\/(?P<tag>[^\d.]+)") | ||
|
||
match = pattern.search(name) | ||
if match: | ||
return match.group("tag") | ||
|
||
# just left properly named tags intact | ||
if name.startswith("v"): | ||
return name | ||
|
||
# fail in case of wrong tag names like "release/unknown" | ||
raise ValueError(f"Wrong tag name: {name}") |