feat(devgen): enhance sanitize_ai_commit_message to handle bolding and labels

- Improve header detection by stripping bolding and cleaning labels like "1. Title:", "### Message:", etc.
- Stop processing lines when encountering a sponsor section
```
This commit is contained in:
sankalp committed 2025-12-24 23:49:37 +05:45
1 parent 40c9b3ca57
commit 37e5d94373
1 file changed
+14 -4
+14 -4
View File
@@ -57,13 +57,23 @@ def sanitize_ai_commit_message(raw_text: str) -> str:
for line in lines:
stripped = line.strip()
if not found_header:
if header_pattern.match(stripped):
# First, strip bolding if it wraps the whole line or parts of it
# This is simpler than handling it in the regex
candidate = stripped.replace("**", "").strip()
# Clean the line by removing labels like "1. Title:", "### Message:", etc.
clean_line = re.sub(
r"^(#+\s+)?(\d+\.?|\*|-)?\s*(Title|Commit Message|Message):\s*",
"",
candidate,
flags=re.IGNORECASE,
).strip()
if header_pattern.match(clean_line):
found_header = True
# Remove bolding if present
clean_line = stripped.replace("**", "").strip()
cleaned_lines.append(clean_line)
else:
# If we hit another header or a known separator, we stop (optional, but keep for now)
# If we hit another header or a known separator, we stop
if "**Sponsor**" in line:
break
cleaned_lines.append(line)