refactor(devgen): enhance AI commit message sanitization

The `sanitize_ai_commit_message` function has been significantly improved to better handle AI-generated commit messages, including support for bolded headers, more robust header detection, and a fallback mechanism for non-conventional messages.

**Enhancements & Refinements:**
- Added comprehensive docstring explaining the function's purpose and behavior
- Improved regex pattern to match conventional commit headers with optional bolding (e.g., **feat: ...**)
- Added case-insensitive matching for commit types
- Implemented a state-based approach with `found_header` flag for clearer logic
- Added automatic removal of bold markers (**) from headers
- Introduced fallback behavior to return the first non-empty line if no conventional header is found
- Improved code structure with better variable naming and comments
- Added early return for empty input strings

**Bug Fixes:**
- Fixed potential issue where the function could return empty strings for non-conventional messages
- Resolved edge case handling for messages without proper headers
```
This commit is contained in:
sankalp committed 2025-12-24 23:29:45 +05:45
1 parent fe7da77ed6
commit d373f95388
3 files changed
+124 -37

No files matched your search

+9 -10
View File
@@ -1,15 +1,14 @@
Analyze the following git diff for the directory `{{ group_name }}` and generate a detailed semantic release commit message4. Format the output as:
1. A summary title in semantic release format (type(scope): summary) — scope can be the directory or 'root'.
2. A short summary paragraph if needed.
3. Bullet points listing the main changes, grouped as 'New Features', 'Enhancements & Refinements', and 'Bug Fixes' if relevant. Use bold for feature/section names.
Analyze the following git diff for `{{ group_name }}` and generate a semantic commit message.
Format:
1. Title: `<type>(<scope>): <summary>` (scope is `{{ group_name }}` or `root`).
2. Optional short summary.
3. Bullet points: `New Features`, `Enhancements`, `Bug Fixes`. Use **bold** for section names.
{% if use_emoji %}
4. Use appropriate emojis for the commit type and sections (e.g., 🚀 for features, 🐛 for bugs).
4. Use emojis (e.g., 🚀, 🐛).
{% else %}
4. Do NOT use any emojis in the commit message.
4. No emojis.
{% endif %}
Output only the commit message, don't include explanations or extra text.
Here is the git diff for `{{ group_name }}`:
Output ONLY the message.
Diff for `{{ group_name }}`:
{{ diff_text }}