Skip to content

Commit ab3e10f

Browse files
authored
Update mistake_title_formatter.py
1 parent 3d3a179 commit ab3e10f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

.github/workflows/mistake_title_formatter.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import re
23
import requests
34

45
def main():
@@ -24,10 +25,17 @@ def main():
2425
response.raise_for_status()
2526
issue = response.json()
2627

27-
# Парсим тело issue
28+
# Извлечение тела issue
2829
body = issue.get("body", "")
29-
subject = next((line.split(": ")[1] for line in body.splitlines() if line.startswith("Предмет")), None)
30-
error_number = next((line.split(": ")[1] for line in body.splitlines() if line.startswith("Номер с ошибкой")), None)
30+
if not body:
31+
raise ValueError("Тело issue пустое. Убедитесь, что issue создано с корректным шаблоном.")
32+
33+
# Парсим тело issue
34+
subject_match = re.search(r"(?i)^### Предмет\s*(.+)$", body, re.MULTILINE)
35+
error_number_match = re.search(r"(?i)^### Номер с ошибкой\s*(.+)$", body, re.MULTILINE)
36+
37+
subject = subject_match.group(1).strip() if subject_match else None
38+
error_number = error_number_match.group(1).strip() if error_number_match else None
3139

3240
if not subject or not error_number:
3341
raise ValueError("Не удалось извлечь 'Предмет' или 'Номер с ошибкой' из тела issue.")

0 commit comments

Comments
 (0)