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:
1 file changed
+14
-4
+14
-4
@@ -57,13 +57,23 @@ def sanitize_ai_commit_message(raw_text: str) -> str:
|
|||||||
for line in lines:
|
for line in lines:
|
||||||
stripped = line.strip()
|
stripped = line.strip()
|
||||||
if not found_header:
|
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
|
found_header = True
|
||||||
# Remove bolding if present
|
|
||||||
clean_line = stripped.replace("**", "").strip()
|
|
||||||
cleaned_lines.append(clean_line)
|
cleaned_lines.append(clean_line)
|
||||||
else:
|
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:
|
if "**Sponsor**" in line:
|
||||||
break
|
break
|
||||||
cleaned_lines.append(line)
|
cleaned_lines.append(line)
|
||||||
|
|||||||
Reference in new issue
Block a user