fixed generate_branch_name
This commit is contained in:
parent
298402ff2b
commit
0d26bd7b06
|
@ -25,7 +25,8 @@ def generate_branch_name(issue_number: str, issue_title: str) -> str:
|
||||||
the text is lowercased, and spaces are replaced with dashes.
|
the text is lowercased, and spaces are replaced with dashes.
|
||||||
"""
|
"""
|
||||||
sanitized = re.sub(r"[^0-9a-zA-Z ]+", "", issue_title)
|
sanitized = re.sub(r"[^0-9a-zA-Z ]+", "", issue_title)
|
||||||
return "issue-" + "-".join(sanitized.lower().split())
|
parts = ['issue', issue_number, *sanitized.lower().split()]
|
||||||
|
return "-".join(parts)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,8 @@ def test_generate_branch_name_normal():
|
||||||
assert branch == "issue-123-some-issue-title"
|
assert branch == "issue-123-some-issue-title"
|
||||||
|
|
||||||
def test_generate_branch_name_special_characters():
|
def test_generate_branch_name_special_characters():
|
||||||
# Test where title contains special characters.
|
|
||||||
branch = generate_branch_name("45", "Issue @ Special!")
|
branch = generate_branch_name("45", "Issue @ Special!")
|
||||||
# This test expects only the space replaced and lower-casing.
|
assert branch == "issue-45-issue-special"
|
||||||
# Adjust the expected value if more sophisticated slugification is added.
|
|
||||||
assert branch == "issue-45-issue-@-special!"
|
|
||||||
|
|
||||||
def test_generate_branch_name_numeric_title():
|
def test_generate_branch_name_numeric_title():
|
||||||
# Test where the title starts with numbers.
|
# Test where the title starts with numbers.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user