fixed generate_branch_name

This commit is contained in:
Jon Michael Aanes 2025-04-13 16:50:50 +02:00
parent 298402ff2b
commit 0d26bd7b06
2 changed files with 3 additions and 5 deletions

View File

@ -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.
"""
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__)

View File

@ -7,11 +7,8 @@ def test_generate_branch_name_normal():
assert branch == "issue-123-some-issue-title"
def test_generate_branch_name_special_characters():
# Test where title contains special characters.
branch = generate_branch_name("45", "Issue @ Special!")
# This test expects only the space replaced and lower-casing.
# Adjust the expected value if more sophisticated slugification is added.
assert branch == "issue-45-issue-@-special!"
assert branch == "issue-45-issue-special"
def test_generate_branch_name_numeric_title():
# Test where the title starts with numbers.