Compare commits
2 Commits
37c9ecf3db
...
298402ff2b
Author | SHA1 | Date | |
---|---|---|---|
298402ff2b | |||
4e014d4df4 |
|
@ -18,7 +18,7 @@ import re
|
||||||
|
|
||||||
from . import secrets
|
from . import secrets
|
||||||
|
|
||||||
def generate_branch_name(issue_title: str) -> str:
|
def generate_branch_name(issue_number: str, issue_title: str) -> str:
|
||||||
"""
|
"""
|
||||||
Create a branch name by sanitizing the issue title.
|
Create a branch name by sanitizing the issue title.
|
||||||
Non-alphanumeric characters (except spaces) are removed,
|
Non-alphanumeric characters (except spaces) are removed,
|
||||||
|
@ -149,7 +149,7 @@ def main():
|
||||||
issue_number = issue.get("number")
|
issue_number = issue.get("number")
|
||||||
issue_description = issue.get("body", "")
|
issue_description = issue.get("body", "")
|
||||||
title = issue.get("title", f"Issue {issue_number}")
|
title = issue.get("title", f"Issue {issue_number}")
|
||||||
branch_name = generate_branch_name(title)
|
branch_name = generate_branch_name(issue_number, title)
|
||||||
try:
|
try:
|
||||||
with tempfile.TemporaryDirectory() as tmpdirname:
|
with tempfile.TemporaryDirectory() as tmpdirname:
|
||||||
process_issue(args, Path(tmpdirname), branch_name, title, issue_description, issue_number)
|
process_issue(args, Path(tmpdirname), branch_name, title, issue_description, issue_number)
|
||||||
|
|
19
test/test_generate_branch_name.py
Normal file
19
test/test_generate_branch_name.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import pytest
|
||||||
|
from aider_gitea.__main__ import generate_branch_name
|
||||||
|
|
||||||
|
def test_generate_branch_name_normal():
|
||||||
|
# Normal case with alphanumeric title.
|
||||||
|
branch = generate_branch_name("123", "Some Issue Title")
|
||||||
|
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!"
|
||||||
|
|
||||||
|
def test_generate_branch_name_numeric_title():
|
||||||
|
# Test where the title starts with numbers.
|
||||||
|
branch = generate_branch_name("789", "123 Numbers Here")
|
||||||
|
assert branch == "issue-789-123-numbers-here"
|
Loading…
Reference in New Issue
Block a user