44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
import re
|
|
|
|
GITEA_PATTERNS = [
|
|
re.compile(r"gitea\s*#(\d+)", re.IGNORECASE),
|
|
re.compile(r"fixes\s+#(\d+)", re.IGNORECASE),
|
|
re.compile(r"closes\s+gitea\s*#(\d+)", re.IGNORECASE),
|
|
]
|
|
|
|
TAIGA_STORY_PATTERNS = [
|
|
re.compile(r"taiga\s*#(\d+)", re.IGNORECASE),
|
|
re.compile(r"TG-(\d+)", re.IGNORECASE),
|
|
re.compile(r"closes\s+taiga\s*#(\d+)", re.IGNORECASE),
|
|
]
|
|
|
|
TAIGA_TASK_PATTERNS = [
|
|
re.compile(r"taiga\s+task\s*#(\d+)", re.IGNORECASE),
|
|
]
|
|
|
|
|
|
def parse_commit_message(message: str) -> dict[str, list[int]]:
|
|
gitea_refs: set[int] = set()
|
|
taiga_story_refs: set[int] = set()
|
|
taiga_task_refs: set[int] = set()
|
|
|
|
for pattern in GITEA_PATTERNS:
|
|
for match in pattern.finditer(message):
|
|
gitea_refs.add(int(match.group(1)))
|
|
|
|
for pattern in TAIGA_TASK_PATTERNS:
|
|
for match in pattern.finditer(message):
|
|
taiga_task_refs.add(int(match.group(1)))
|
|
|
|
for pattern in TAIGA_STORY_PATTERNS:
|
|
for match in pattern.finditer(message):
|
|
ref = int(match.group(1))
|
|
if ref not in taiga_task_refs:
|
|
taiga_story_refs.add(ref)
|
|
|
|
return {
|
|
"gitea": sorted(gitea_refs),
|
|
"taiga_story": sorted(taiga_story_refs),
|
|
"taiga_task": sorted(taiga_task_refs),
|
|
}
|