refactor(commitgen): improve emoji handling and sanitization in commit message generation
This commit is contained in:
2 files changed
+14
-17
No files matched your search
+3
-4
@@ -11,16 +11,15 @@
|
||||
|
||||
🔄 Changed
|
||||
- Replaced Ruff linter with Black
|
||||
|
||||
🐛 Fixed
|
||||
- Improved changelog generation and sanitization of AI output
|
||||
- Improved changelog generation to handle existing files and duplicate headers
|
||||
|
||||
🗑️ Removed
|
||||
- Removed duplicate changelog entries
|
||||
|
||||
📝 Documentation
|
||||
- Updated changelog for v0.1.0 release
|
||||
- Updated changelog for v0.1.1 release
|
||||
- Recommended installation using pipx and uv
|
||||
- Updated changelog for v0.1.1 release
|
||||
|
||||
## v0.1.0
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ Output ONLY the commit message in the correct format{" with emoji" if self.use_e
|
||||
else:
|
||||
message = lines[0] if lines else "🔧 chore: update code"
|
||||
|
||||
# Apply or remove emoji based on configuration
|
||||
# Apply or remove emoji based on configuration (strict removal when disabled)
|
||||
if self.use_emoji:
|
||||
if not any(
|
||||
emoji in message for emoji in ["✨", "🐛", "📚", "💅", "♻️", "✅", "🔧"]
|
||||
@@ -116,13 +116,12 @@ Output ONLY the commit message in the correct format{" with emoji" if self.use_e
|
||||
elif message.startswith("chore"):
|
||||
message = "🔧 " + message
|
||||
else:
|
||||
message = "🔧 " + message # fallback
|
||||
message = "🔧 " + message
|
||||
else:
|
||||
# Strip known emojis if present
|
||||
for emoji in ["✨ ", "🐛 ", "📚 ", "💅 ", "♻️ ", "✅ ", "🔧 "]:
|
||||
if message.startswith(emoji):
|
||||
message = message[len(emoji) :]
|
||||
break
|
||||
# Remove any known emojis anywhere in the message
|
||||
for emoji in ["✨", "🐛", "📚", "💅", "♻️", "✅", "🔧"]:
|
||||
message = message.replace(emoji, "")
|
||||
message = " ".join(message.split())
|
||||
|
||||
return message
|
||||
|
||||
@@ -220,7 +219,7 @@ Output ONLY the commit message in the correct format{" with emoji" if self.use_e
|
||||
else:
|
||||
message = lines[0] if lines else "🔧 chore: update code"
|
||||
|
||||
# Ensure proper emoji prefix
|
||||
# Ensure proper emoji prefix or strip strictly according to config
|
||||
if self.use_emoji:
|
||||
if not any(
|
||||
emoji in message for emoji in ["✨", "🐛", "📚", "💅", "♻️", "✅", "🔧"]
|
||||
@@ -240,12 +239,11 @@ Output ONLY the commit message in the correct format{" with emoji" if self.use_e
|
||||
elif message.startswith("chore"):
|
||||
message = "🔧 " + message
|
||||
else:
|
||||
message = "🔧 " + message # fallback
|
||||
message = "🔧 " + message
|
||||
else:
|
||||
for emoji in ["✨ ", "🐛 ", "📚 ", "💅 ", "♻️ ", "✅ ", "🔧 "]:
|
||||
if message.startswith(emoji):
|
||||
message = message[len(emoji) :]
|
||||
break
|
||||
for emoji in ["✨", "🐛", "📚", "💅", "♻️", "✅", "🔧"]:
|
||||
message = message.replace(emoji, "")
|
||||
message = " ".join(message.split())
|
||||
|
||||
return message
|
||||
|
||||
|
||||
Reference in new issue
Block a user