-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomerslow-priority
Description
Problem
Currently, the sanitizeCommitMessage() function removes all emojis from commit messages. There's a TODO comment indicating this is a known limitation.
Location: utils/sanitizeCommitMessage.js:1
// TODO should allow emojis
export function sanitizeCommitMessage(message) {
// Unicode regex: Allow only all characters (including Japanese and Traditional Chinese), numbers, spaces, and symbols.
return message.replace(/[^\p{L}\p{N}\s.:@<>\/-]/gu, '')
}Current behavior:
sanitizeCommitMessage('fix: bug ππ₯π₯')
// Result: 'fix: bug ' (emojis removed)Test expectation (tests/utils/sanitizeCommitMessage.test.js:47-49):
it('should remove emojis and unsupported unicode', () => {
expect(sanitizeCommitMessage('fix: bug ππ₯π₯')).toBe('fix: bug ')
})User Request
Many developers use emojis in commit messages for visual clarity:
- π for bug fixes
- β¨ for new features
- π₯ for removing code/files
- π for documentation
- β»οΈ for refactoring
- π for deployment
- β for tests
Popular projects like gitmoji encourage this practice.
Proposed Solution
Option 1: Allow All Emojis (Simple)
/**
* Sanitizes commit message by removing dangerous characters
* Allows: letters, numbers, spaces, common symbols, and emojis
* @param {string} message - Raw commit message
* @returns {string} Sanitized commit message
*/
export function sanitizeCommitMessage(message) {
// Allow all characters except potentially dangerous ones
// \p{L} = letters, \p{N} = numbers, \p{Emoji} = emojis
return message.replace(/[^\p{L}\p{N}\p{Emoji}\s.:@<>\/-]/gu, '')
}Test update:
it('should allow emojis in commit messages', () => {
expect(sanitizeCommitMessage('fix: bug ππ₯π₯')).toBe('fix: bug ππ₯π₯')
})Option 2: Allow Specific Emoji Categories
/**
* Sanitizes commit message
* Allows common emojis but blocks potentially problematic ones
*/
export function sanitizeCommitMessage(message) {
// Allow: letters, numbers, emojis, and safe symbols
// Block: control characters, private use area, format characters
return message.replace(
/[^\p{L}\p{N}\p{Emoji_Presentation}\s.:@<>\/-]/gu,
''
)
}Option 3: Configurable Emoji Support
// Add to config
{
"model": "gpt-5-mini",
"language": "English",
"prefixEnabled": true,
"allowEmojis": true // β New option
}
// In sanitizeCommitMessage
export function sanitizeCommitMessage(message, allowEmojis = true) {
if (allowEmojis) {
return message.replace(/[^\p{L}\p{N}\p{Emoji}\s.:@<>\/-]/gu, '')
}
// Original behavior (no emojis)
return message.replace(/[^\p{L}\p{N}\s.:@<>\/-]/gu, '')
}
// Add CLI command
program
.command('emoji')
.description('Toggle emoji support in commit messages')
.action(async () => {
const response = await prompts({
type: 'select',
name: 'value',
message: 'Allow emojis in commit messages?',
choices: [
{ title: 'Enable emojis π', value: true },
{ title: 'Disable emojis', value: false },
],
initial: config.allowEmojis ? 0 : 1,
})
saveConfig({ allowEmojis: response.value })
console.log(`Emojis ${response.value ? 'enabled' : 'disabled'}`)
})Considerations
Pros
- β Better visual clarity in commit history
- β Aligns with popular practices (gitmoji)
- β OpenAI may generate emoji-enhanced messages
- β No functional impact (emojis are valid in git)
Cons
β οΈ Some terminal/font configurations don't display emojis wellβ οΈ Can look unprofessional in some corporate environmentsβ οΈ May complicate commit message parsing
Git Compatibility
Emojis work perfectly in git commit messages:
$ git commit -m "β¨ Add new feature"
$ git log
commit abc123...
β¨ Add new featureRecommendation
Option 3 (Configurable) is the most flexible:
- Default: Enabled (modern practice)
- Users who don't want emojis can disable
- Backward compatible
Implementation Plan
- Update
sanitizeCommitMessage()to acceptallowEmojisparameter - Add emoji configuration option to config file
- Add
git gpt emojicommand to toggle - Update tests to verify emoji support
- Update documentation
- Consider asking OpenAI to suggest appropriate emojis
Acceptance Criteria
-
sanitizeCommitMessage()preserves emojis when enabled - Add
allowEmojisconfig option (default: true) - Add
git gpt emojicommand - Update tests for emoji support
- Update README with emoji examples
- Add integration test with emoji commit
Priority
Low - Feature request, not a blocker
Related
- Quality analysis report: claudedocs/quality-analysis-report.md section 2.1
- Gitmoji
- Conventional Commits with Emojis
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomerslow-priority