fixed generate_branch_name
All checks were successful
Run Python tests (through Pytest) / Test (push) Successful in 24s
Verify Python project can be installed, loaded and have version checked / Test (push) Successful in 22s

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

View File

@ -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.