Coverage for src\gibr\branch.py: 80%
10 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-20 09:51 +0300
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-20 09:51 +0300
1"""Branch name generation logic."""
4class BranchName:
5 """Generate branch names based on config and issue info."""
7 def __init__(self, format_string: str):
8 """Construct BranchName object."""
9 self.format = format_string
11 def generate(self, issue) -> str:
12 """Return formatted branch name."""
13 # The config placeholders match keys in this mapping
14 data = {
15 "issuetype": issue.type,
16 "issue": issue.id,
17 "title": issue.sanitized_title,
18 }
20 # Simple Python str.format expansion
21 try:
22 branch_name = self.format.format(**data)
23 except KeyError as e:
24 raise ValueError(f"Unknown placeholder in format: {e.args[0]}")
26 return branch_name