Fixed commit-msg hook warning on emoji-prefixed commits#28400
Conversation
ref https://linear.app/ghost/issue/PLA-76 - the "user-facing changes should start with an emoji" check tested the first word against [[:punct:]], which never matches an actual emoji - as a result the warning fired on every correctly-prefixed commit (🐛, ✨, …) while plain-punctuation prefixes like *Fixed or :bug: passed - detect emoji by stripping ASCII bytes from the first word instead, so real emoji prefixes pass and plain-ASCII subjects still warn
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe PR updates the emoji validation logic in the Git commit-msg hook. The hook now detects emoji in the first word of the commit subject by removing all ASCII bytes using 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
The
commit-msghook's "user-facing changes should start with an emoji" check never recognizes an actual emoji, so the warning fires on every commit that correctly follows our emoji convention.In
.github/hooks/commit-msg.bashit tested the first word against POSIX[[:punct:]]:Emoji (🐛 ✨ 🎨 🌐 💡) are not punctuation, so the negated test is always true → the warning always prints. Ironically a non-emoji prefix like
*Fixedor:bug:passed the check.Solution
Detect emoji by stripping ASCII bytes from the first word and checking whether anything (a multi-byte emoji) remains:
tris portable across the macOS/Linux shells contributors use, and this keeps the check a non-blocking warning.Testing
Verified against representative subjects:
🐛 Fixed …✨ Added …🌐 Updated …Fixed …(no emoji)*Fixed …ref https://linear.app/ghost/issue/PLA-76