-
-
Notifications
You must be signed in to change notification settings - Fork 2
β¨ feat: feat: add auto emoji for commit #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Warning Rate limit exceeded@hoangsinh0601 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 28 seconds before requesting another review. β How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. π¦ How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. π Files selected for processing (1)
WalkthroughAdds a commit-emoji system: docs, a Bash CLI helper, Git hook installer, and two Git hooks (prepare-commit-msg and commit-msg) to detect, insert, validate, and enforce emoji-prefixed or type-prefixed commit messages. All changes are additions; no public API modifications. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant Git as Git
participant Prep as prepare-commit-msg (hook)
participant Msg as commit-msg (hook)
participant Repo as .git/COMMIT_EDITMSG
Dev->>Git: git commit -m "feat: add login"
Git->>Prep: run prepare-commit-msg (with commit message file)
rect rgb(235,245,255)
note right of Prep #99ccff: detect_commit_type()\n(strict mode: require type)\nget_emoji_for_type()
Prep->>Repo: write "β¨ feat: add login" (or exit with error)
end
Git->>Msg: run commit-msg (validate)
rect rgb(240,255,240)
note right of Msg #ccffcc: validate format\ncheck type in VALID_TYPES\nverify emoji matches type
Msg-->>Git: exit 0 (ok) or exit 1 (reject)
end
Git-->>Dev: commit accepted or rejected with guidance
sequenceDiagram
autonumber
actor Dev as Developer
participant CLI as commit-emoji-helper.sh
participant Local as Local Input/Output
Dev->>CLI: cli detect/add/validate "message..."
rect rgb(250,245,235)
note right of CLI #ffd9b3: detect_commit_type()\nget_emoji_for_type()\nadd_emoji()/validate_message()
CLI->>Local: print suggested formatted message / validation result
end
Estimated code review effortπ― 4 (Complex) | β±οΈ ~45 minutes Poem
β¨ Finishing Touchesπ§ͺ Generate unit tests
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 |
β Commit Validation PassedAll commits follow the conventional commit format! π Thank you for following our commit standards. This helps with:
|
|
π¨ Emergency Labeling Applied This PR was automatically labeled as "β Needs Review" because no other labels could be applied. Please:
This ensures proper organization and searchability of PRs. |
1 similar comment
|
π¨ Emergency Labeling Applied This PR was automatically labeled as "β Needs Review" because no other labels could be applied. Please:
This ensures proper organization and searchability of PRs. |
β Commit Validation FailedYour commits don't follow the MANDATORY EMOJI commit format. Please fix them before merging. π REQUIRED Format (Emoji is MANDATORY):
β Valid Types with Required Emojis:
π Examples (Emoji REQUIRED):
β Invalid Examples:
π§ How to Fix:
For more details, check the Conventional Commits specification. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
π§Ή Nitpick comments (5)
docs/AUTO_EMOJI_GUIDE.md (2)
110-116: Add concrete Git alias setup commands.Without config steps,
git emojiwonβt work.The helper script is available as a Git alias: ```bash -git emoji [command] [options] +git emoji [command] [options] + +# Setup (run once): +git config alias.emoji '!bash scripts/commit-emoji-helper.sh' + +# Usage: +git emoji list--- `200-204`: **Refresh βRelated Filesβ to reflect actual locations.** ```diff -- `.git/hooks/prepare-commit-msg` - Auto-emoji addition -- `.git/hooks/commit-msg` - Message validation +- `.husky/prepare-commit-msg` - Auto-emoji addition +- `.husky/commit-msg` - Message validation +- `.husky/ci-check-commits.sh` - CI validation - `scripts/commit-emoji-helper.sh` - Helper utilities - `.github/workflows/setup-labels.yml` - Label definitionsscripts/commit-emoji-helper.sh (3)
109-114: βAlready has emojiβ path should print only the message to stdout and send the warning to stderr.Improves composability in pipelines (e.g., command substitution).
- if echo "$message" | grep -qE '^[^[:space:]]+ [a-z]+:'; then - echo -e "${YELLOW}β οΈ Message already has emoji:${NC} $message" - return 0 - fi + if echo "$message" | grep -qE '^[^[:space:]]+ [a-z]+:'; then + echo -e "${YELLOW}β οΈ Message already has emoji:${NC} $message" 1>&2 + echo "$message" + return 0 + fi
1-13: Optional hardening: enable strict mode and drop unused color vars.Reduces footguns and satisfies ShellCheck warnings (unused PURPLE/CYAN).
-#!/bin/bash +#!/bin/bash +set -Eeuo pipefail @@ -PURPLE='\033[0;35m' -CYAN='\033[0;36m'
17-31: Keep emoji mappings consistent across scripts.
get_emoji_for_typehere returns empty string for unknown types, whilescripts/test-emoji-validation.shuses "β". Standardize behavior across the repo to avoid confusion.Do you want this helper to echo "β" for unknown types (to match tests) or keep empty and tighten validation to ensure unknown types are rejected?
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (2)
docs/AUTO_EMOJI_GUIDE.md(1 hunks)scripts/commit-emoji-helper.sh(1 hunks)
π§° Additional context used
𧬠Code graph analysis (2)
docs/AUTO_EMOJI_GUIDE.md (1)
.husky/ci-check-commits.sh (3)
main(106-178)validate_commit(39-103)get_emoji_for_type(20-36)
scripts/commit-emoji-helper.sh (2)
.husky/ci-check-commits.sh (3)
main(106-178)get_emoji_for_type(20-36)validate_commit(39-103)scripts/test-emoji-validation.sh (1)
get_emoji_for_type(19-35)
πͺ LanguageTool
docs/AUTO_EMOJI_GUIDE.md
[grammar] ~1-~1: There might be a mistake here.
Context: # π¨ Auto Emoji Guide for TiLoKit This guide explains how to use the autom...
(QB_NEW_EN)
[grammar] ~5-~5: There might be a mistake here.
Context: ... TiLoKit's Git workflow. ## π Overview TiLoKit automatically adds appropriate e...
(QB_NEW_EN)
[grammar] ~16-~16: There might be a mistake here.
Context: ...or emoji management ## π οΈ How It Works ### 1. Automatic Emoji Addition When you co...
(QB_NEW_EN)
[grammar] ~46-~46: There might be a mistake here.
Context: ... issue ``` ## π Supported Commit Types | Type | Emoji | Description ...
(QB_NEW_EN)
[grammar] ~63-~63: There might be a mistake here.
Context: ...rade, deps | ## π― Usage Examples ### Basic Usage ```bash # Auto-detected as ...
(QB_NEW_EN)
[grammar] ~106-~106: There might be a mistake here.
Context: ...oji interactive ``` ## π§ Configuration ### Git Alias The helper script is availabl...
(QB_NEW_EN)
[grammar] ~124-~124: There might be a mistake here.
Context: ...] [options] ``` ## π« What Gets Skipped The auto-emoji system skips: - Merge co...
(QB_NEW_EN)
[grammar] ~128-~128: There might be a mistake here.
Context: ... Merge commits (automatically generated) - Squash commits - Cherry-pick commits - E...
(QB_NEW_EN)
[grammar] ~129-~129: There might be a mistake here.
Context: ...utomatically generated) - Squash commits - Cherry-pick commits - Empty messages - M...
(QB_NEW_EN)
[grammar] ~130-~130: There might be a mistake here.
Context: ...) - Squash commits - Cherry-pick commits - Empty messages - Messages that already h...
(QB_NEW_EN)
[grammar] ~131-~131: There might be a mistake here.
Context: ...s - Cherry-pick commits - Empty messages - Messages that already have emojis ## π...
(QB_NEW_EN)
[grammar] ~134-~134: There might be a mistake here.
Context: ...ready have emojis ## π Detection Logic The system uses keyword matching to dete...
(QB_NEW_EN)
[grammar] ~138-~138: There might be a mistake here.
Context: ...sage starts with type:, uses that type 2. Keyword Matching: Analyzes message con...
(QB_NEW_EN)
[grammar] ~139-~139: There might be a mistake here.
Context: ...es message content for relevant keywords 3. Fallback: Defaults to chore if no ty...
(QB_NEW_EN)
[grammar] ~146-~146: There might be a mistake here.
Context: ...to ensure: - Proper emoji-type matching - Correct format: `emoji type: description...
(QB_NEW_EN)
[grammar] ~147-~147: There might be a mistake here.
Context: ...r emoji-type matching - Correct format: emoji type: description - No leading/trailing whitespace - Valid c...
(QB_NEW_EN)
[grammar] ~148-~148: There might be a mistake here.
Context: ...iption` - No leading/trailing whitespace - Valid commit types ## π¨ Customization ...
(QB_NEW_EN)
[grammar] ~151-~151: There might be a mistake here.
Context: ... Valid commit types ## π¨ Customization ### Adding New Types To add new commit type...
(QB_NEW_EN)
[grammar] ~165-~165: There might be a mistake here.
Context: ...he helper script. ## π Troubleshooting ### Common Issues 1. **Wrong Emoji Detected...
(QB_NEW_EN)
[grammar] ~176-~176: There might be a mistake here.
Context: ...on Errors** - Ensure proper format: emoji type: description - Check for leading/trailing whitespace 3...
(QB_NEW_EN)
[grammar] ~179-~179: There might be a mistake here.
Context: ...itespace 3. Helper Script Not Working - Ensure script is executable: `chmod +x s...
(QB_NEW_EN)
[grammar] ~180-~180: There might be a mistake here.
Context: ...ing** - Ensure script is executable: chmod +x scripts/commit-emoji-helper.sh - Check Git alias: `git config alias.emoji...
(QB_NEW_EN)
[grammar] ~191-~191: There might be a mistake here.
Context: ...rt GIT_DEBUG=1 ``` ## π Best Practices 1. Be Descriptive: Write clear, descripti...
(QB_NEW_EN)
[grammar] ~205-~205: There might be a mistake here.
Context: ...els.yml- Label definitions ## π‘ Tips - Usegit emoji interactive` for guided m...
(QB_NEW_EN)
[grammar] ~214-~214: There might be a mistake here.
Context: ...descriptive --- Happy Committing! π
(QB_NEW_EN)
πͺ GitHub Check: markdownlint
docs/AUTO_EMOJI_GUIDE.md
[failure] 214-214: Emphasis used instead of a heading
docs/AUTO_EMOJI_GUIDE.md:214 MD036/no-emphasis-as-heading Emphasis used instead of a heading [Context: "Happy Committing! π"] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md036.md
πͺ GitHub Actions: markdownlint
docs/AUTO_EMOJI_GUIDE.md
[error] 214-214: markdownlint MD036/no-emphasis-as-heading: Emphasis used instead of a heading [Context: Happy Committing! π] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md036.md
πͺ Shellcheck (0.10.0)
scripts/commit-emoji-helper.sh
[warning] 11-11: PURPLE appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 12-12: CYAN appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 62-62: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 115-115: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 116-116: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 137-137: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 138-138: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 191-191: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 192-192: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 193-193: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 225-225: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 226-226: Declare and assign separately to avoid masking return values.
(SC2155)
| ## π« What Gets Skipped | ||
|
|
||
| The auto-emoji system skips: | ||
|
|
||
| - Merge commits (automatically generated) | ||
| - Squash commits | ||
| - Cherry-pick commits | ||
| - Empty messages | ||
| - Messages that already have emojis | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π‘ Verification agent
π§© Analysis chain
Docs vs CI behavior mismatch: skip rules are overstated.
CI script only skips GitHub auto-merge commits; it does not skip squash or cherry-pick. Align docs or update CI.
- The auto-emoji system skips:
-
-- Merge commits (automatically generated)
-- Squash commits
-- Cherry-pick commits
-- Empty messages
-- Messages that already have emojis
+ The auto-emoji system skips:
+
+- GitHub auto-generated merge commits (CI only)
+- Empty messages
+- Messages that already include an emoji+type prefix
+
+ Note:
+ - Squash and cherry-pick commits are NOT skipped by CI validation.π Script executed:
#!/bin/bash
# List CI workflows to identify commit validation steps
echo "## .github/workflows content:"
ls -R .github/workflows
# Search for commit-skip logic referencing merge, squash, cherry-pick in scripts and workflows
echo -e "\n## Searching for skip patterns in .github and scripts:"
rg -n -e "skip" -e "ignore" -g "*.sh" -g "*.js" -g "*.py" -g ".github/**"
rg -n -e "merge" -e "squash" -e "cherry-pick" -g "*.sh" -g "*.js" -g "*.py" -g ".github/**"Length of output: 1271
π Script executed:
#!/bin/bash
# Display the commit validation workflow to inspect skip logic
sed -n '1,200p' .github/workflows/validate-commits.ymlLength of output: 3750
π Script executed:
#!/bin/bash
# Display the first 200 lines of the commit validation script
sed -n '1,200p' .husky/ci-check-commits.shLength of output: 6161
Align docs skip rules with CI behavior. Update docs/AUTO_EMOJI_GUIDE.md (lines 124β133) so only GitHub auto-generated merge commits are skipped; remove squash, cherry-pick, empty-message, and emoji-prefixed entries.
@@ docs/AUTO_EMOJI_GUIDE.md:124-133
- The auto-emoji system skips:
-
-- Merge commits (automatically generated)
-- Squash commits
-- Cherry-pick commits
-- Empty messages
-- Messages that already have emojis
+ The auto-emoji system skips:
+
+- GitHub auto-generated merge commits
+
+ Note: squash commits, cherry-pick commits, empty messages, and emoji-prefixed commits are validated by CI.π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ## π« What Gets Skipped | |
| The auto-emoji system skips: | |
| - Merge commits (automatically generated) | |
| - Squash commits | |
| - Cherry-pick commits | |
| - Empty messages | |
| - Messages that already have emojis | |
| ## π« What Gets Skipped | |
| The auto-emoji system skips: | |
| - GitHub auto-generated merge commits | |
| Note: squash commits, cherry-pick commits, empty messages, and emoji-prefixed commits are validated by CI. |
π§° Tools
πͺ LanguageTool
[grammar] ~124-~124: There might be a mistake here.
Context: ...] [options] ``` ## π« What Gets Skipped The auto-emoji system skips: - Merge co...
(QB_NEW_EN)
[grammar] ~128-~128: There might be a mistake here.
Context: ... Merge commits (automatically generated) - Squash commits - Cherry-pick commits - E...
(QB_NEW_EN)
[grammar] ~129-~129: There might be a mistake here.
Context: ...utomatically generated) - Squash commits - Cherry-pick commits - Empty messages - M...
(QB_NEW_EN)
[grammar] ~130-~130: There might be a mistake here.
Context: ...) - Squash commits - Cherry-pick commits - Empty messages - Messages that already h...
(QB_NEW_EN)
[grammar] ~131-~131: There might be a mistake here.
Context: ...s - Cherry-pick commits - Empty messages - Messages that already have emojis ## π...
(QB_NEW_EN)
π€ Prompt for AI Agents
In docs/AUTO_EMOJI_GUIDE.md around lines 124 to 133, the skip-rules list is too
broad; update the section so it only states that GitHub auto-generated merge
commits are skipped and remove the entries for squash commits, cherry-pick
commits, empty messages, and messages that already have emojis. Edit the bullet
list to contain a single item clarifying "GitHub auto-generated merge commits"
(and adjust surrounding wording if necessary) so the doc matches CI behavior.
| To add new commit types, edit: | ||
|
|
||
| 1. `.git/hooks/prepare-commit-msg` - Add detection logic | ||
| 2. `.git/hooks/commit-msg` - Add validation rules | ||
| 3. `scripts/commit-emoji-helper.sh` - Add helper functions | ||
|
|
||
| ### Modifying Emojis | ||
|
|
||
| Update the `get_emoji_for_type()` function in both hook files and the helper script. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
Use Husky paths instead of .git/hooks.
Project uses Husky; point customization to .husky hooks.
-1. `.git/hooks/prepare-commit-msg` - Add detection logic
-2. `.git/hooks/commit-msg` - Add validation rules
-3. `scripts/commit-emoji-helper.sh` - Add helper functions
+1. `.husky/prepare-commit-msg` - Add detection logic
+2. `.husky/commit-msg` - Add validation rules (CI uses `.husky/ci-check-commits.sh`)
+3. `scripts/commit-emoji-helper.sh` - Add helper functionsπ Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| To add new commit types, edit: | |
| 1. `.git/hooks/prepare-commit-msg` - Add detection logic | |
| 2. `.git/hooks/commit-msg` - Add validation rules | |
| 3. `scripts/commit-emoji-helper.sh` - Add helper functions | |
| ### Modifying Emojis | |
| Update the `get_emoji_for_type()` function in both hook files and the helper script. | |
| To add new commit types, edit: | |
| 1. `.husky/prepare-commit-msg` - Add detection logic | |
| 2. `.husky/commit-msg` - Add validation rules (CI uses `.husky/ci-check-commits.sh`) | |
| 3. `scripts/commit-emoji-helper.sh` - Add helper functions | |
| ### Modifying Emojis | |
| Update the `get_emoji_for_type()` function in both hook files and the helper script. |
π€ Prompt for AI Agents
In docs/AUTO_EMOJI_GUIDE.md around lines 155 to 163, the guide incorrectly
references .git/hooks; update the instructions to use Husky-managed hooks in the
.husky directory. Change the three bullet points to point at
.husky/prepare-commit-msg, .husky/commit-msg and scripts/commit-emoji-helper.sh
(or the equivalent helper script), and update the note about modifying
get_emoji_for_type() to state that the function should be updated in the
corresponding .husky hook scripts and the helper script. Ensure paths and
examples refer to .husky so contributors edit the Husky hooks rather than
.git/hooks.
| local emoji="${EMOJI_MAP[$type]}" | ||
| local description="" | ||
|
|
||
| case "$type" in | ||
| "feat") description="new features" ;; | ||
| "fix") description="bug fixes" ;; | ||
| "docs") description="documentation changes" ;; | ||
| "refactor") description="code refactoring" ;; | ||
| "perf") description="performance improvements" ;; | ||
| "test") description="adding or updating tests" ;; | ||
| "build") description="build system changes" ;; | ||
| "ci") description="CI/CD changes" ;; | ||
| "chore") description="maintenance tasks" ;; | ||
| "style") description="code style changes" ;; | ||
| "revert") description="reverting previous commits" ;; | ||
| "release") description="version releases" ;; | ||
| esac | ||
|
|
||
| echo -e " ${GREEN}$emoji $type${NC} - $description" | ||
| done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undefined EMOJI_MAP causes runtime error in list_emojis.
EMOJI_MAP is never defined; use get_emoji_for_type instead. Also fix trailing usage line that references stale $emoji $type.
- for type in "${VALID_TYPES[@]}"; do
- local emoji="${EMOJI_MAP[$type]}"
+ for type in "${VALID_TYPES[@]}"; do
+ local emoji
+ emoji="$(get_emoji_for_type "$type")"
@@
- echo -e " ${GREEN}$emoji $type${NC} - $description"
+ echo -e " ${GREEN}${emoji} ${type}${NC} - ${description}"
done
echo
- echo -e "${YELLOW}π‘ Usage:${NC} $emoji $type: your commit message"
+ echo -e "${YELLOW}π‘ Usage:${NC} β¨ feat: your commit message"π€ Prompt for AI Agents
In scripts/commit-emoji-helper.sh around lines 156 to 175, the function
references an undefined EMOJI_MAP and prints a stale "$emoji $type" usage;
replace the EMOJI_MAP lookup with a call to the existing get_emoji_for_type
function (e.g. emoji="$(get_emoji_for_type "$type")"), keep the case block to
set description, ensure emoji is populated for unknown types (provide a default
inside get_emoji_for_type or fall back to a hardcoded default here), remove any
direct EMOJI_MAP references, and update the echo line to use the resolved $emoji
and $type variables so the script no longer errors at runtime.
| # Check format: emoji type: description | ||
| if echo "$message" | grep -qE '^[^[:space:]]+ [a-z]+: .+'; then | ||
| local emoji=$(echo "$message" | sed -E 's/^([^[:space:]]+) [a-z]+: .*/\1/') | ||
| local type=$(echo "$message" | sed -E 's/^[^[:space:]]+ ([a-z]+): .*/\1/') | ||
| local expected_emoji=$(get_emoji_for_type "$type") | ||
|
|
||
| if [[ "$emoji" == "$expected_emoji" ]]; then | ||
| echo -e "${GREEN}β Valid commit message:${NC} $message" | ||
| echo -e "${GREEN}β Emoji matches type:${NC} $emoji for $type" | ||
| else | ||
| echo -e "${RED}β Invalid emoji for type '$type'${NC}" | ||
| echo -e "${YELLOW}π Expected:${NC} $expected_emoji" | ||
| echo -e "${YELLOW}π Found:${NC} $emoji" | ||
| fi | ||
| else | ||
| echo -e "${RED}β Invalid format. Expected: emoji type: description${NC}" | ||
| echo -e "${YELLOW}π Example:${NC} β¨ feat: add new feature" | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
Add type validation before comparing emojis in validate_message.
Currently an unknown type (e.g., β¨ foo: msg) reports βInvalid emojiβ rather than βInvalid typeβ.
- if echo "$message" | grep -qE '^[^[:space:]]+ [a-z]+: .+'; then
+ if echo "$message" | grep -qE '^[^[:space:]]+ [a-z]+: .+'; then
local emoji=$(echo "$message" | sed -E 's/^([^[:space:]]+) [a-z]+: .*/\1/')
local type=$(echo "$message" | sed -E 's/^[^[:space:]]+ ([a-z]+): .*/\1/')
- local expected_emoji=$(get_emoji_for_type "$type")
+ local expected_emoji=$(get_emoji_for_type "$type")
+
+ # Ensure type is one of VALID_TYPES
+ local valid=false
+ for t in "${VALID_TYPES[@]}"; do
+ [[ "$type" == "$t" ]] && valid=true && break
+ done
+ if [[ "$valid" == false ]]; then
+ echo -e "${RED}β Invalid type '${type}'${NC}"
+ echo -e "${YELLOW}β
Valid types:${NC} ${VALID_TYPES[*]}"
+ return 1
+ fi
@@
- else
+ else
echo -e "${RED}β Invalid emoji for type '$type'${NC}"
echo -e "${YELLOW}π Expected:${NC} $expected_emoji"
echo -e "${YELLOW}π Found:${NC} $emoji"
fiπ§° Tools
πͺ Shellcheck (0.10.0)
[warning] 191-191: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 192-192: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 193-193: Declare and assign separately to avoid masking return values.
(SC2155)
π€ Prompt for AI Agents
In scripts/commit-emoji-helper.sh around lines 189 to 206, validate the commit
"type" before comparing emojis: call get_emoji_for_type and if it returns empty
or an indicator of unknown type, print an "Invalid type" error (e.g., show the
unknown type and list valid types or example) and skip the emoji comparison;
only proceed to compare emoji == expected_emoji when expected_emoji is
non-empty. Ensure the new branch uses the same colorized messages and examples
as the existing error paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
β»οΈ Duplicate comments (3)
docs/AUTO_EMOJI_GUIDE.md (3)
127-136: Align skip rules with CI (only GitHub auto-merge is skipped).Docs still list squash/cherry-pick/empty/emoji-prefixed as skipped; CI validates them. Align with CI wording.
- The auto-emoji system skips: - -- Merge commits (automatically generated) -- Squash commits -- Cherry-pick commits -- Empty messages -- Messages that already have emojis + The auto-emoji system skips: + +- GitHub auto-generated merge commits (CI only) + + Note: squash commits, cherry-pick commits, empty messages, and emoji-prefixed commits are validated by CI.
158-166: Use Husky-managed hooks, not .git/hooks.Project uses Husky; point contributors to .husky.
-1. `.git/hooks/prepare-commit-msg` - Add detection logic -2. `.git/hooks/commit-msg` - Add validation rules -3. `scripts/commit-emoji-helper.sh` - Add helper functions +1. `.husky/prepare-commit-msg` - Add detection logic +2. `.husky/commit-msg` - Add validation rules (CI uses `.husky/ci-check-commits.sh`) +3. `scripts/commit-emoji-helper.sh` - Add helper functions-Update the `get_emoji_for_type()` function in both hook files and the helper script. +Update the `get_emoji_for_type()` function in the Husky hook(s) and the helper script.
217-217: Fix markdownlint MD036: use a heading, not emphasis.This currently fails the pipeline.
-**Happy Committing! π** +## Happy Committing! π
π§Ή Nitpick comments (2)
docs/AUTO_EMOJI_GUIDE.md (2)
137-144: Clarify that detection is helper-only, not CI.Avoid implying CI performs keyword detection.
-The system uses keyword matching to detect commit types: +The helper script uses keyword matching to suggest commit types (CI does not auto-detect):
42-45: Tighten wording about auto-add behavior.Be explicit that auto-add is off and suggest using the helper to format before committing.
-The system no longer automatically adds emojis. You must specify the type explicitly. +The system does not auto-add emojis in strict mode. Use the helper (`git emoji add|interactive`) to format messages before committing.
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (1)
docs/AUTO_EMOJI_GUIDE.md(1 hunks)
π§° Additional context used
𧬠Code graph analysis (1)
docs/AUTO_EMOJI_GUIDE.md (1)
.husky/ci-check-commits.sh (3)
main(106-178)validate_commit(39-103)get_emoji_for_type(20-36)
πͺ LanguageTool
docs/AUTO_EMOJI_GUIDE.md
[grammar] ~1-~1: There might be a mistake here.
Context: # π¨ Auto Emoji Guide for TiLoKit This guide explains how to use the autom...
(QB_NEW_EN)
[grammar] ~5-~5: There might be a mistake here.
Context: ... TiLoKit's Git workflow. ## π Overview TiLoKit automatically adds appropriate e...
(QB_NEW_EN)
[grammar] ~17-~17: There might be a mistake here.
Context: ...per commit messages ## π οΈ How It Works ### 1. Strict Type Requirement **ALL commit...
(QB_NEW_EN)
[grammar] ~46-~46: There might be a mistake here.
Context: ...xplicitly. ## π Supported Commit Types | Type | Emoji | Description ...
(QB_NEW_EN)
[grammar] ~63-~63: There might be a mistake here.
Context: ...rade, deps | ## π― Usage Examples ### Required Type Format ```bash # Type onl...
(QB_NEW_EN)
[grammar] ~109-~109: There might be a mistake here.
Context: ...oji interactive ``` ## π§ Configuration ### Git Alias The helper script is availabl...
(QB_NEW_EN)
[grammar] ~127-~127: There might be a mistake here.
Context: ...] [options] ``` ## π« What Gets Skipped The auto-emoji system skips: - Merge co...
(QB_NEW_EN)
[grammar] ~131-~131: There might be a mistake here.
Context: ... Merge commits (automatically generated) - Squash commits - Cherry-pick commits - E...
(QB_NEW_EN)
[grammar] ~132-~132: There might be a mistake here.
Context: ...utomatically generated) - Squash commits - Cherry-pick commits - Empty messages - M...
(QB_NEW_EN)
[grammar] ~133-~133: There might be a mistake here.
Context: ...) - Squash commits - Cherry-pick commits - Empty messages - Messages that already h...
(QB_NEW_EN)
[grammar] ~134-~134: There might be a mistake here.
Context: ...s - Cherry-pick commits - Empty messages - Messages that already have emojis ## π...
(QB_NEW_EN)
[grammar] ~137-~137: There might be a mistake here.
Context: ...ready have emojis ## π Detection Logic The system uses keyword matching to dete...
(QB_NEW_EN)
[grammar] ~141-~141: There might be a mistake here.
Context: ...sage starts with type:, uses that type 2. Keyword Matching: Analyzes message con...
(QB_NEW_EN)
[grammar] ~142-~142: There might be a mistake here.
Context: ...es message content for relevant keywords 3. Fallback: Defaults to chore if no ty...
(QB_NEW_EN)
[grammar] ~149-~149: There might be a mistake here.
Context: ...to ensure: - Proper emoji-type matching - Correct format: `emoji type: description...
(QB_NEW_EN)
[grammar] ~150-~150: There might be a mistake here.
Context: ...r emoji-type matching - Correct format: emoji type: description - No leading/trailing whitespace - Valid c...
(QB_NEW_EN)
[grammar] ~151-~151: There might be a mistake here.
Context: ...iption` - No leading/trailing whitespace - Valid commit types ## π¨ Customization ...
(QB_NEW_EN)
[grammar] ~154-~154: There might be a mistake here.
Context: ... Valid commit types ## π¨ Customization ### Adding New Types To add new commit type...
(QB_NEW_EN)
[grammar] ~168-~168: There might be a mistake here.
Context: ...he helper script. ## π Troubleshooting ### Common Issues 1. **Wrong Emoji Detected...
(QB_NEW_EN)
[grammar] ~179-~179: There might be a mistake here.
Context: ...on Errors** - Ensure proper format: emoji type: description - Check for leading/trailing whitespace 3...
(QB_NEW_EN)
[grammar] ~182-~182: There might be a mistake here.
Context: ...itespace 3. Helper Script Not Working - Ensure script is executable: `chmod +x s...
(QB_NEW_EN)
[grammar] ~183-~183: There might be a mistake here.
Context: ...ing** - Ensure script is executable: chmod +x scripts/commit-emoji-helper.sh - Check Git alias: `git config alias.emoji...
(QB_NEW_EN)
[grammar] ~194-~194: There might be a mistake here.
Context: ...rt GIT_DEBUG=1 ``` ## π Best Practices 1. Be Descriptive: Write clear, descripti...
(QB_NEW_EN)
[grammar] ~208-~208: There might be a mistake here.
Context: ...els.yml- Label definitions ## π‘ Tips - Usegit emoji interactive` for guided m...
(QB_NEW_EN)
[grammar] ~217-~217: There might be a mistake here.
Context: ...descriptive --- Happy Committing! π
(QB_NEW_EN)
πͺ GitHub Check: markdownlint
docs/AUTO_EMOJI_GUIDE.md
[failure] 217-217: Emphasis used instead of a heading
docs/AUTO_EMOJI_GUIDE.md:217 MD036/no-emphasis-as-heading Emphasis used instead of a heading [Context: "Happy Committing! π"] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md036.md
πͺ GitHub Actions: markdownlint
docs/AUTO_EMOJI_GUIDE.md
[error] 217-217: MD036/no-emphasis-as-heading Emphasis used instead of a heading [Context: "Happy Committing! π"] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md036.md
| - **Strict Validation**: Rejects commits without proper type format | ||
| - **Manual Type Required**: All commits must use explicit type format (`type: message` or `emoji type: message`) | ||
| - **Validation**: Ensures emojis match the commit type when present | ||
| - **Helper Tools**: Command-line utilities for emoji management | ||
| - **Guided Creation**: Interactive mode for creating proper commit messages | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π‘ Verification agent
π§© Analysis chain
Docs vs CI: emoji+type is mandatory (not optional).
CI rejects type-only messages. Update bullets to state βemoji + type: descriptionβ is required and remove βtype-onlyβ as acceptable.
Apply:
- - **Strict Validation**: Rejects commits without proper type format
- - **Manual Type Required**: All commits must use explicit type format (`type: message` or `emoji type: message`)
- - **Validation**: Ensures emojis match the commit type when present
+ - **Strict Validation**: CI requires emoji + type format
+ - **Emoji + Type Required**: All commits MUST be `emoji type: message`
+ - **Validation**: Ensures the emoji matches the declared commit typeRun to confirm CI behavior:
π Script executed:
#!/bin/bash
rg -n 'no_emoji_pattern|emoji_pattern|Required: emoji type' .husky/ci-check-commits.shLength of output: 434
Enforce emoji + type commit format in docs
docs/AUTO_EMOJI_GUIDE.md (lines 11β16): replace bullets so only emoji type: message is allowed and remove any βtype-onlyβ allowance:
- - **Strict Validation**: Rejects commits without proper type format
- - **Manual Type Required**: All commits must use explicit type format (`type: message` or `emoji type: message`)
- - **Validation**: Ensures emojis match the commit type when present
+ - **Strict Validation**: CI requires emoji + type format
+ - **Emoji + Type Required**: All commits MUST be `emoji type: message`
+ - **Validation**: Ensures the emoji matches the declared commit typeπ Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - **Strict Validation**: Rejects commits without proper type format | |
| - **Manual Type Required**: All commits must use explicit type format (`type: message` or `emoji type: message`) | |
| - **Validation**: Ensures emojis match the commit type when present | |
| - **Helper Tools**: Command-line utilities for emoji management | |
| - **Guided Creation**: Interactive mode for creating proper commit messages | |
| - **Strict Validation**: CI requires emoji + type format | |
| - **Emoji + Type Required**: All commits MUST be `emoji type: message` | |
| - **Validation**: Ensures the emoji matches the declared commit type | |
| - **Helper Tools**: Command-line utilities for emoji management | |
| - **Guided Creation**: Interactive mode for creating proper commit messages |
π€ Prompt for AI Agents
In docs/AUTO_EMOJI_GUIDE.md around lines 11 to 16, the current bullets allow
both "type: message" and "emoji type: message" formats; update the text so only
the "emoji type: message" format is permitted and remove any mention or
allowance of type-only commits. Replace the five bullets with statements that
(1) strictly require emoji + type before the colon, (2) reject commits without
an emoji prefix, (3) validate that the emoji matches the declared type, (4) keep
helper tools/interactive mode but describe them as enforcing or assisting the
emoji+type format, and (5) remove any line that suggests manual type-only
commits are acceptable.
| **ALL commits must have a proper type format. Commits without types are automatically rejected.** | ||
|
|
||
| β **Valid formats:** | ||
|
|
||
| ```bash | ||
| git commit -m "feat: add new authentication feature" # Type only | ||
| git commit -m "β¨ feat: add new authentication feature" # With emoji | ||
| git commit -m "fix: resolve memory leak issue" # Type only | ||
| git commit -m "π fix: resolve memory leak issue" # With emoji | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix βValid formatsβ to remove type-only examples.
These examples contradict CI. Keep only emoji+type.
-**ALL commits must have a proper type format. Commits without types are automatically rejected.**
+**ALL commits must be in emoji + type format. Commits without the emoji or type are rejected.**
@@
-```bash
-git commit -m "feat: add new authentication feature" # Type only
-git commit -m "β¨ feat: add new authentication feature" # With emoji
-git commit -m "fix: resolve memory leak issue" # Type only
-git commit -m "π fix: resolve memory leak issue" # With emoji
-```
+```bash
+git commit -m "β¨ feat: add new authentication feature"
+git commit -m "π fix: resolve memory leak issue"
+```π€ Prompt for AI Agents
In docs/AUTO_EMOJI_GUIDE.md around lines 21 to 30, the "Valid formats" section
shows type-only commit examples which contradict CI rules; update the examples
to include only emoji+type forms by removing the type-only lines and keeping the
emoji-prefixed examples so the block lists only allowed commit message formats.
| ### What Gets Rejected | ||
|
|
||
| ```bash | ||
| # These will be REJECTED | ||
| git commit -m "add user authentication" # No type | ||
| git commit -m "Fixed bug" # No type | ||
| git commit -m "Updated docs" # No type | ||
| git commit -m "FEAT: add feature" # Uppercase | ||
| git commit -m "feat:add feature" # Missing space | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add βtype-onlyβ to rejected examples.
Make rejection examples match CI checks.
```bash
# These will be REJECTED
+git commit -m "feat: add user authentication" # Missing emoji
git commit -m "add user authentication" # No typeπ€ Prompt for AI Agents
In docs/AUTO_EMOJI_GUIDE.md around lines 79 to 88, the rejected examples list is
missing a "type-only" case required by CI; add an entry showing a commit with
only a conventional type and no emoji (e.g., a git commit message like feat: add
user authentication) and annotate it as "# Missing emoji" so the rejected
examples fully match the CI checks.
| ## π Related Files | ||
|
|
||
| - `.git/hooks/prepare-commit-msg` - Auto-emoji addition | ||
| - `.git/hooks/commit-msg` - Message validation | ||
| - `scripts/commit-emoji-helper.sh` - Helper utilities | ||
| - `.github/workflows/setup-labels.yml` - Label definitions | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
Fix βRelated Filesβ to reference actual validation assets.
Point to Husky + validation workflow; remove unrelated labels workflow.
-- `.git/hooks/prepare-commit-msg` - Auto-emoji addition
-- `.git/hooks/commit-msg` - Message validation
+- `.husky/prepare-commit-msg` - Auto-emoji addition (if used)
+- `.husky/commit-msg` - Local message validation
- `scripts/commit-emoji-helper.sh` - Helper utilities
-- `.github/workflows/setup-labels.yml` - Label definitions
+- `.husky/ci-check-commits.sh` - CI validation logic
+- `.github/workflows/validate-commits.yml` - CI workflow invoking validationπ Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ## π Related Files | |
| - `.git/hooks/prepare-commit-msg` - Auto-emoji addition | |
| - `.git/hooks/commit-msg` - Message validation | |
| - `scripts/commit-emoji-helper.sh` - Helper utilities | |
| - `.github/workflows/setup-labels.yml` - Label definitions | |
| ## π Related Files | |
| - `.husky/prepare-commit-msg` - Auto-emoji addition (if used) | |
| - `.husky/commit-msg` - Local message validation | |
| - `scripts/commit-emoji-helper.sh` - Helper utilities | |
| - `.husky/ci-check-commits.sh` - CI validation logic | |
| - `.github/workflows/validate-commits.yml` - CI workflow invoking validation |
π€ Prompt for AI Agents
In docs/AUTO_EMOJI_GUIDE.md around lines 201β207, the "Related Files" list
points to an unrelated labels workflow; replace it with the actual Husky hooks
and CI validation assets: reference .husky/prepare-commit-msg and
.husky/commit-msg (or equivalent Husky hook files),
scripts/commit-emoji-helper.sh, the commitlint config (e.g.,
commitlint.config.js or .commitlintrc.js), and the CI workflow that runs commit
validation (e.g., .github/workflows/commit-validation.yml), removing the
.github/workflows/setup-labels.yml entry so the list reflects the real
validation tooling.
080d104 to
c13e78b
Compare
β Commit Validation FailedYour commits don't follow the MANDATORY EMOJI commit format. Please fix them before merging. π REQUIRED Format (Emoji is MANDATORY):
β Valid Types with Required Emojis:
π Examples (Emoji REQUIRED):
β Invalid Examples:
π§ How to Fix:
For more details, check the Conventional Commits specification. |
c13e78b to
7fc9217
Compare
β Commit Validation PassedAll commits follow the conventional commit format! π Thank you for following our commit standards. This helps with:
|
β Commit Validation PassedAll commits follow the conventional commit format! π Thank you for following our commit standards. This helps with:
|
β Commit Validation PassedAll commits follow the conventional commit format! π Thank you for following our commit standards. This helps with:
|
β Commit Validation PassedAll commits follow the conventional commit format! π Thank you for following our commit standards. This helps with:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
β»οΈ Duplicate comments (7)
docs/AUTO_EMOJI_GUIDE.md (7)
11-16: Docs contradict CI: emoji + type is mandatory.Align Features bullets with CI which requires
emoji type: description.Apply:
- - **Strict Validation**: Rejects commits without proper type format - - **Manual Type Required**: All commits must use explicit type format (`type: message` or `emoji type: message`) - - **Validation**: Ensures emojis match the commit type when present + - **Strict Validation**: CI requires emoji + type format + - **Emoji + Type Required**: All commits MUST be `emoji type: description` + - **Validation**: Ensures the emoji matches the declared commit type
21-30: Remove typeβonly from βValid formatsβ.Only emoji+type is allowed by CI.
-β **Valid formats:** +β **Valid format:** ```bash -git commit -m "feat: add new authentication feature" # Type only -git commit -m "β¨ feat: add new authentication feature" # With emoji -git commit -m "fix: resolve memory leak issue" # Type only -git commit -m "π fix: resolve memory leak issue" # With emoji +git commit -m "β¨ feat: add new authentication feature" +git commit -m "π fix: resolve memory leak issue"
63-77: Usage examples: make emoji required, not optional.Replace βType only (recommended)β and βWith emoji (optional)β with a single required form.
-### Required Type Format +### Required Commit Format ```bash -# Type only (recommended) -git commit -m "feat: add user authentication" -git commit -m "fix: resolve login bug" -git commit -m "docs: update installation guide" - -# With emoji (optional) -git commit -m "β¨ feat: add new dashboard" -git commit -m "π fix: resolve memory leak" -git commit -m "π docs: update API documentation" +# Emoji + type (required) +git commit -m "β¨ feat: add user authentication" +git commit -m "π fix: resolve login bug" +git commit -m "π docs: update installation guide"
79-88: Add βtype-onlyβ to rejected examples.CI rejects messages missing the emoji.
```bash # These will be REJECTED +git commit -m "feat: add user authentication" # Missing emoji git commit -m "add user authentication" # No type git commit -m "Fixed bug" # No type git commit -m "Updated docs" # No type git commit -m "FEAT: add feature" # Uppercase git commit -m "feat:add feature" # Missing space--- `127-136`: **Fix skip rules to match CI.** Only GitHub auto-generated merge commits are skipped by CI. ```diff -## π« What Gets Skipped - -The auto-emoji system skips: - -- Merge commits (automatically generated) -- Squash commits -- Cherry-pick commits -- Empty messages -- Messages that already have emojis +## π« What Gets Skipped (CI) + +The CI validation skips only GitHub auto-generated merge commits. + +Note: squash, cherry-pick, empty, and emoji-prefixed commits are all validated by CI.
201-207: Update βRelated Filesβ to actual validation assets.-- `.git/hooks/prepare-commit-msg` - Auto-emoji addition -- `.git/hooks/commit-msg` - Message validation +- `.githooks/prepare-commit-msg` - Auto-emoji addition (source; installed to `.git/hooks/`) +- `.githooks/commit-msg` - Local message validation (source; installed to `.git/hooks/`) - `scripts/commit-emoji-helper.sh` - Helper utilities -- `.github/workflows/setup-labels.yml` - Label definitions +- `.husky/ci-check-commits.sh` - CI validation logic +- `.github/workflows/validate-commits.yml` - CI workflow invoking validation
154-166: Edit the right files: point to .githooks sources, not .git/hooks.Contributors should modify tracked hook sources, then reinstall.
-To add new commit types, edit: - -1. `.git/hooks/prepare-commit-msg` - Add detection logic -2. `.git/hooks/commit-msg` - Add validation rules -3. `scripts/commit-emoji-helper.sh` - Add helper functions +To add new commit types, edit: + +1. `.githooks/prepare-commit-msg` - Detection/auto-insert logic +2. `.githooks/commit-msg` - Local validation rules +3. `scripts/commit-emoji-helper.sh` - Helper functions + +Then run `./scripts/install-hooks.sh` to install into `.git/hooks/`.And:
-Update the `get_emoji_for_type()` function in both hook files and the helper script. +Update `get_emoji_for_type()` in `.githooks/*` and `scripts/commit-emoji-helper.sh` (CI uses `.husky/ci-check-commits.sh` with its own mapping).
π§Ή Nitpick comments (18)
.githooks/commit-msg (3)
63-70: Unused variables: COMMIT_PATTERN_WITH_ never used*Either use them in the checks or remove.
-COMMIT_PATTERN_WITH_EMOJI='^[^[:space:]]+ [a-z]+: .+' -COMMIT_PATTERN_WITHOUT_EMOJI='^[a-z]+: .+' +COMMIT_PATTERN_WITH_EMOJI='^[^[:space:]]+ [a-z]+: .+' +COMMIT_PATTERN_WITHOUT_EMOJI='^[a-z]+: .+' +# Use the patternsAnd replace inline grep/regex uses to reference these vars.
140-145: Portable sed
sed -Eis okay on GNU/macOS, but BusyBox may lack-E. If portability matters, prefer-rwith GNU detection or switch to awk.
13-27: DRY: Consolidate commit-type & emoji mappings
scripts/commit-emoji-helper.sh already defines VALID_TYPES & get_emoji_for_type(), but these are duplicated in .githooks/commit-msg, .githooks/prepare-commit-msg and scripts/test-emoji-validation.shβremove the copies and source the helper in each. Update docs/AUTO_EMOJI_GUIDE.md to reference only the shared implementation..githooks/prepare-commit-msg (5)
22-31: Duplicate emoji-present checks; consolidate to oneTwo slightly different regex checks do the same thing. Keep one to reduce confusion.
-# Skip if message already has emoji (starts with emoji) -if echo "$COMMIT_MSG" | grep -qE '^[^[:space:]]+ [a-z]+:'; then - echo -e "${BLUE}βΉοΈ Commit message already has emoji, skipping auto-add${NC}" - exit 0 -fi ... -# STRICT TAG MODE: Only allow explicit tags, auto-add emoji after tag -# Check if message already has emoji format -if echo "$COMMIT_MSG" | grep -qE '^[^[:space:]]+ [a-z]+: .+'; then +if echo "$COMMIT_MSG" | grep -qE '^[^[:space:]]+ [a-z]+: .+'; then echo -e "${BLUE}βΉοΈ Commit message already has emoji, skipping auto-add${NC}" exit 0 fiAlso applies to: 101-106
60-99: Dead code: detect_commit_type is unused in STRICT modeEither wire it in as a fallback or remove to avoid confusion. If you want auto-detection when no explicit tag is present, call it and rewrite.
-# Auto-detect commit type from message content -detect_commit_type() { +detect_commit_type() { ... }And after Line 145, optionally:
- echo -e "${YELLOW}β οΈ No valid tag found, manual tag required${NC}" + # Try auto-detect as a fallback + AUTO_TYPE=$(detect_commit_type "$COMMIT_MSG") + if [[ -n "$AUTO_TYPE" ]]; then + EMOJI=$(get_emoji_for_type "$AUTO_TYPE") + NEW_MSG="$EMOJI $AUTO_TYPE: $COMMIT_MSG" + echo "$NEW_MSG" > "$COMMIT_MSG_FILE" + echo -e "${GREEN}π¨ Auto-detected and added emoji:${NC} $EMOJI $AUTO_TYPE" + exit 0 + fi + echo -e "${YELLOW}β οΈ No valid tag found, manual tag required${NC}"
1-1: Shell robustnessUse env shebang and stricter options.
-#!/bin/bash +#!/usr/bin/env bash ... -# This hook runs before commit-msg validation +# This hook runs before commit-msg validation +set -Eeuo pipefailNote: ensure commands wrapped in conditionals so set -e doesnβt cause unintended exits.
Also applies to: 6-6
15-18: Unused variableCOMMIT_SHA is assigned but never used.
-COMMIT_SHA=$3
41-58: Use sharedcommit-emoji-helper.shin hook scripts
Replace the duplicatedget_emoji_for_typefunction andVALID_TYPESarray in.githooks/prepare-commit-msg(and other hook scripts) by adding at the top:source scripts/commit-emoji-helper.shand removing the inline definitions.
scripts/install-hooks.sh (4)
6-6: Stricter shell optionsImprove failure semantics.
-set -e +set -Eeuo pipefail
26-41: Make success conditional and back up existing hooksCurrently prints success even if files are missing. Track per-hook status and back up any existing files.
-# Copy hooks from .githooks to .git/hooks -if [[ -f ".githooks/commit-msg" ]]; then - cp .githooks/commit-msg .git/hooks/commit-msg - chmod +x .git/hooks/commit-msg - echo -e "${GREEN}β Installed commit-msg hook${NC}" +ok=true +# Copy hooks from .githooks to $HOOKS_DIR +if [[ -f ".githooks/commit-msg" ]]; then + [[ -f "$HOOKS_DIR/commit-msg" ]] && cp "$HOOKS_DIR/commit-msg" "$HOOKS_DIR/commit-msg.bak.$(date +%s)" + cp .githooks/commit-msg "$HOOKS_DIR/commit-msg" + chmod +x "$HOOKS_DIR/commit-msg" + echo -e "${GREEN}β Installed commit-msg hook${NC}" else echo -e "${YELLOW}β οΈ commit-msg hook not found in .githooks/${NC}" + ok=false fi - -if [[ -f ".githooks/prepare-commit-msg" ]]; then - cp .githooks/prepare-commit-msg .git/hooks/prepare-commit-msg - chmod +x .git/hooks/prepare-commit-msg - echo -e "${GREEN}β Installed prepare-commit-msg hook${NC}" +if [[ -f ".githooks/prepare-commit-msg" ]]; then + [[ -f "$HOOKS_DIR/prepare-commit-msg" ]] && cp "$HOOKS_DIR/prepare-commit-msg" "$HOOKS_DIR/prepare-commit-msg.bak.$(date +%s)" + cp .githooks/prepare-commit-msg "$HOOKS_DIR/prepare-commit-msg" + chmod +x "$HOOKS_DIR/prepare-commit-msg" + echo -e "${GREEN}β Installed prepare-commit-msg hook${NC}" else echo -e "${YELLOW}β οΈ prepare-commit-msg hook not found in .githooks/${NC}" + ok=false fi
43-50: Only celebrate on full success, and reflect hooksDir in hints-echo -e "${GREEN}π Git hooks installed successfully!${NC}" +if [[ "$ok" == true ]]; then + echo -e "${GREEN}π Git hooks installed successfully!${NC}" +else + echo -e "${YELLOW}β οΈ Hooks installation incomplete. See warnings above.${NC}" +fi ... -echo -e "${YELLOW}π‘ To test:${NC} git commit -m \"feat: add new feature\"" +echo -e "${YELLOW}π‘ To test:${NC} git commit -m \"feat: add new feature\" (emoji will be auto-added)"
3-5: Architecture: unify githooks vs husky scriptsYou have similar logic in .husky and .githooks (types/mapping/validation). Consider one source of truth (shared helper + both hooks/CI source it).
docs/AUTO_EMOJI_GUIDE.md (2)
42-45: Auto-emoji behavior is unclear/inconsistent with .githooks.This section says auto-add is disabled, but .githooks/prepare-commit-msg exists and auto-adds. Clarify scope: local hook may auto-insert; CI only validates.
-### 2. Auto-Emoji Addition (Disabled in Strict Mode) - -The system no longer automatically adds emojis. You must specify the type explicitly. +### 2. Auto-Emoji Addition (Local hook) + +Locally, the `prepare-commit-msg` hook can auto-insert the correct emoji. CI still requires the final commit message to be in `emoji type: description` format. If the hook is disabled/bypassed, include the emoji yourself.
141-144: Clarify detection logic applicability.Detection applies to the local prepare-commit-msg hook, not CI.
-The system uses keyword matching to detect commit types: +The local `prepare-commit-msg` hook can use keyword matching to detect commit types (CI does not perform detection, only validation):.githooks/README.md (4)
9-9: Fix markdownlint MD009: remove trailing spaces.-- **Requirements**: +- **Requirements**:
8-13: Call out CI requirement explicitly.Add a note that CI enforces
emoji type: description; local hooks help you comply.- **Purpose**: Validates commit messages - **Requirements**: - Must have valid commit type (feat, fix, docs, etc.) - - Must have emoji (auto-added by prepare-commit-msg) + - Must have emoji (auto-added by prepare-commit-msg; CI will reject messages without emoji) - **Rejects**: Commits without proper format
15-20: Verify prepare-commit-msg βrejects invalid commit typesβ.Typically prepare-commit-msg mutates, commit-msg rejects. If prepare hook doesnβt reject, reword.
- **Behavior**: - Only works with valid commit types - Automatically prepends appropriate emoji - - Rejects invalid commit types + - For invalid types, no emoji is added; rejection happens in `commit-msg`
48-53: Avoid confusion with CI by annotating transformation.Make it clear these are typed inputs that the hook rewrites.
-### β Valid Commits +### β Valid Commits (typed β rewritten by prepare-commit-msg)
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (5)
.githooks/README.md(1 hunks).githooks/commit-msg(1 hunks).githooks/prepare-commit-msg(1 hunks)docs/AUTO_EMOJI_GUIDE.md(1 hunks)scripts/install-hooks.sh(1 hunks)
π§° Additional context used
𧬠Code graph analysis (5)
scripts/install-hooks.sh (2)
.husky/hooks/install-hooks.sh (1)
install_hook(41-66).husky/check-hooks.sh (3)
main(44-67)auto_install_hooks(26-41)check_hooks_installed(15-23)
.githooks/commit-msg (1)
.husky/ci-check-commits.sh (3)
validate_commit(39-103)main(106-178)get_emoji_for_type(20-36)
.githooks/prepare-commit-msg (2)
.husky/ci-check-commits.sh (3)
main(106-178)validate_commit(39-103)get_emoji_for_type(20-36)scripts/test-emoji-validation.sh (1)
get_emoji_for_type(19-35)
.githooks/README.md (1)
.husky/ci-check-commits.sh (2)
main(106-178)validate_commit(39-103)
docs/AUTO_EMOJI_GUIDE.md (1)
.husky/ci-check-commits.sh (3)
main(106-178)validate_commit(39-103)get_emoji_for_type(20-36)
πͺ LanguageTool
.githooks/README.md
[grammar] ~9-~9: There might be a mistake here.
Context: ...ates commit messages - Requirements: - Must have valid commit type (feat, fix, ...
(QB_NEW_EN)
[grammar] ~10-~10: There might be a mistake here.
Context: ... messages - Requirements: - Must have valid commit type (feat, fix, docs, etc...
(QB_NEW_EN)
[grammar] ~11-~11: There might be a mistake here.
Context: ...emoji (auto-added by prepare-commit-msg) - Rejects: Commits without proper format...
(QB_NEW_EN)
[grammar] ~15-~15: There might be a mistake here.
Context: ...e**: Auto-adds emojis to commit messages - Behavior: - Only works with valid co...
(QB_NEW_EN)
[grammar] ~16-~16: There might be a mistake here.
Context: ...mojis to commit messages - Behavior: - Only works with valid commit types - A...
(QB_NEW_EN)
[grammar] ~31-~31: There might be a mistake here.
Context: ...it Types | Type | Emoji | Description | |------|-------|-------------| | feat ...
(QB_NEW_EN)
[grammar] ~32-~32: There might be a mistake here.
Context: ...ription | |------|-------|-------------| | feat | β¨ | New features | | fix | ...
(QB_NEW_EN)
[grammar] ~33-~33: There might be a mistake here.
Context: ...---------| | feat | β¨ | New features | | fix | π | Bug fixes | | docs | π...
(QB_NEW_EN)
[grammar] ~34-~34: There might be a mistake here.
Context: ...ew features | | fix | π | Bug fixes | | docs | π | Documentation | | `refac...
(QB_NEW_EN)
[grammar] ~35-~35: There might be a mistake here.
Context: ... fixes | | docs | π | Documentation | | refactor | β»οΈ | Code refactoring | |...
(QB_NEW_EN)
[grammar] ~36-~36: There might be a mistake here.
Context: ...| | refactor | β»οΈ | Code refactoring | | perf | β‘ | Performance | | test | ...
(QB_NEW_EN)
[grammar] ~37-~37: There might be a mistake here.
Context: ...factoring | | perf | β‘ | Performance | | test | π§ͺ | Tests | | build | π οΈ ...
(QB_NEW_EN)
[grammar] ~38-~38: There might be a mistake here.
Context: ... | Performance | | test | π§ͺ | Tests | | build | π οΈ | Build system | | ci ...
(QB_NEW_EN)
[grammar] ~39-~39: There might be a mistake here.
Context: ...Tests | | build | π οΈ | Build system | | ci | π | CI/CD | | chore | π§Ή | M...
(QB_NEW_EN)
[grammar] ~40-~40: There might be a mistake here.
Context: ...οΈ | Build system | | ci | π | CI/CD | | chore | π§Ή | Maintenance | | style...
(QB_NEW_EN)
[grammar] ~41-~41: There might be a mistake here.
Context: ...| CI/CD | | chore | π§Ή | Maintenance | | style | π¨ | Code style | | revert...
(QB_NEW_EN)
[grammar] ~42-~42: There might be a mistake here.
Context: ...ntenance | | style | π¨ | Code style | | revert | βͺ | Revert | | release | ...
(QB_NEW_EN)
[grammar] ~43-~43: There might be a mistake here.
Context: ...| Code style | | revert | βͺ | Revert | | release | π | Release | ## Example...
(QB_NEW_EN)
[grammar] ~44-~44: There might be a mistake here.
Context: ... | Revert | | release | π | Release | ## Examples ### β
Valid Commits ```bash gi...
(QB_NEW_EN)
docs/AUTO_EMOJI_GUIDE.md
[grammar] ~1-~1: There might be a mistake here.
Context: # π¨ Auto Emoji Guide for TiLoKit This guide explains how to use the autom...
(QB_NEW_EN)
[grammar] ~5-~5: There might be a mistake here.
Context: ... TiLoKit's Git workflow. ## π Overview TiLoKit automatically adds appropriate e...
(QB_NEW_EN)
[grammar] ~17-~17: There might be a mistake here.
Context: ...per commit messages ## π οΈ How It Works ### 1. Strict Type Requirement **ALL commit...
(QB_NEW_EN)
[grammar] ~46-~46: There might be a mistake here.
Context: ...xplicitly. ## π Supported Commit Types | Type | Emoji | Description ...
(QB_NEW_EN)
[grammar] ~63-~63: There might be a mistake here.
Context: ...rade, deps | ## π― Usage Examples ### Required Type Format ```bash # Type onl...
(QB_NEW_EN)
[grammar] ~109-~109: There might be a mistake here.
Context: ...oji interactive ``` ## π§ Configuration ### Git Alias The helper script is availabl...
(QB_NEW_EN)
[grammar] ~127-~127: There might be a mistake here.
Context: ...] [options] ``` ## π« What Gets Skipped The auto-emoji system skips: - Merge co...
(QB_NEW_EN)
[grammar] ~131-~131: There might be a mistake here.
Context: ... Merge commits (automatically generated) - Squash commits - Cherry-pick commits - E...
(QB_NEW_EN)
[grammar] ~132-~132: There might be a mistake here.
Context: ...utomatically generated) - Squash commits - Cherry-pick commits - Empty messages - M...
(QB_NEW_EN)
[grammar] ~133-~133: There might be a mistake here.
Context: ...) - Squash commits - Cherry-pick commits - Empty messages - Messages that already h...
(QB_NEW_EN)
[grammar] ~134-~134: There might be a mistake here.
Context: ...s - Cherry-pick commits - Empty messages - Messages that already have emojis ## π...
(QB_NEW_EN)
[grammar] ~137-~137: There might be a mistake here.
Context: ...ready have emojis ## π Detection Logic The system uses keyword matching to dete...
(QB_NEW_EN)
[grammar] ~149-~149: There might be a mistake here.
Context: ...to ensure: - Proper emoji-type matching - Correct format: `emoji type: description...
(QB_NEW_EN)
[grammar] ~150-~150: There might be a mistake here.
Context: ...r emoji-type matching - Correct format: emoji type: description - No leading/trailing whitespace - Valid c...
(QB_NEW_EN)
[grammar] ~151-~151: There might be a mistake here.
Context: ...iption` - No leading/trailing whitespace - Valid commit types ## π¨ Customization ...
(QB_NEW_EN)
[grammar] ~154-~154: There might be a mistake here.
Context: ... Valid commit types ## π¨ Customization ### Adding New Types To add new commit type...
(QB_NEW_EN)
[grammar] ~168-~168: There might be a mistake here.
Context: ...he helper script. ## π Troubleshooting ### Common Issues 1. **Wrong Emoji Detected...
(QB_NEW_EN)
[grammar] ~179-~179: There might be a mistake here.
Context: ...on Errors** - Ensure proper format: emoji type: description - Check for leading/trailing whitespace 3...
(QB_NEW_EN)
[grammar] ~182-~182: There might be a mistake here.
Context: ...itespace 3. Helper Script Not Working - Ensure script is executable: `chmod +x s...
(QB_NEW_EN)
[grammar] ~183-~183: There might be a mistake here.
Context: ...ing** - Ensure script is executable: chmod +x scripts/commit-emoji-helper.sh - Check Git alias: `git config alias.emoji...
(QB_NEW_EN)
[grammar] ~194-~194: There might be a mistake here.
Context: ...rt GIT_DEBUG=1 ``` ## π Best Practices 1. Be Descriptive: Write clear, descripti...
(QB_NEW_EN)
[grammar] ~208-~208: There might be a mistake here.
Context: ...els.yml- Label definitions ## π‘ Tips - Usegit emoji interactive` for guided m...
(QB_NEW_EN)
[grammar] ~217-~217: There might be a mistake here.
Context: ...escriptive --- ## Happy Committing! π
(QB_NEW_EN)
πͺ GitHub Check: markdownlint
.githooks/README.md
[failure] 9-9: Trailing spaces
.githooks/README.md:9:20 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md009.md
πͺ GitHub Actions: markdownlint
.githooks/README.md
[error] 9-9: MD009/no-trailing-spaces: Trailing spaces detected on line 9.
β° Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: integration-test (vue, js)
| # Skip merge commits (they are auto-generated by Git/GitHub) | ||
| if [[ $COMMIT_MSG =~ ^Merge\ .*\ into\ .* ]] || [[ $COMMIT_MSG =~ ^Merge\ branch\ .* ]] || [[ $COMMIT_MSG =~ ^Merge\ pull\ request\ .* ]] || [[ $COMMIT_MSG =~ ^Merge\ release\ .* ]]; then | ||
| echo -e "${GREEN}β Merge commit detected - skipping validation${NC}" | ||
| exit 0 | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert workflow will be blocked
git revert generates messages like Revert "...", which will be rejected. Either skip these or auto-map them to βͺ revert:. Minimal fix: skip native reverts.
-# Skip merge commits (they are auto-generated by Git/GitHub)
-if [[ $COMMIT_MSG =~ ^Merge\ .*\ into\ .* ]] || [[ $COMMIT_MSG =~ ^Merge\ branch\ .* ]] || [[ $COMMIT_MSG =~ ^Merge\ pull\ request\ .* ]] || [[ $COMMIT_MSG =~ ^Merge\ release\ .* ]]; then
+# Skip merge/revert commits (auto-generated by Git/GitHub)
+if [[ $COMMIT_MSG =~ ^Merge\ .*\ into\ .* ]] || [[ $COMMIT_MSG =~ ^Merge\ branch\ .* ]] || [[ $COMMIT_MSG =~ ^Merge\ pull\ request\ .* ]] || [[ $COMMIT_MSG =~ ^Merge\ release\ .* ]] || [[ $COMMIT_MSG =~ ^Revert\ " ]]; then
echo -e "${GREEN}β
Merge commit detected - skipping validation${NC}"
exit 0
fiOptionally, auto-transform reverts instead of skipping (ask if you want a patch).
Also applies to: 137-146
π€ Prompt for AI Agents
.githooks/commit-msg around lines 54-58 (also apply same change to lines
137-146): the hook currently rejects commit messages that start with Revert
"..." which blocks git revert; update the pattern handling to either skip
validation for native git revert messages or normalize them to a conventional
prefix (e.g., map Revert "Foo" to "revert: Foo"). Minimal fix: detect messages
matching ^Revert\ \"(.*)\"$ and exit 0 (skip validation) for those, or on
normalization branch extract the inner text and rewrite the commit message to
start with "revert: " before running the rest of the validation; apply the same
change at the other affected block (lines 137-146).
| # Check for scope usage (not allowed) | ||
| if echo "$COMMIT_MSG" | grep -qE '^[a-z]+\([^)]+\):'; then | ||
| echo -e "${RED}β Scopes are not allowed in commit messages!${NC}" | ||
| echo -e "${YELLOW}π Invalid:${NC} ${RED}feat(ci): something${NC}" | ||
| echo -e "${YELLOW}π Valid:${NC} ${GREEN}ci: something${NC}" | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
Scope-block only catches type-only; emoji+scope bypasses it
"β¨ feat(scope): ..." currently slips through. If scopes are disallowed, detect both with and without emoji.
-if echo "$COMMIT_MSG" | grep -qE '^[a-z]+\([^)]+\):'; then
+if echo "$COMMIT_MSG" | grep -qE '^[a-z]+\([^)]+\):|^[^[:space:]]+ [a-z]+\([^)]+\):'; thenπ Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Check for scope usage (not allowed) | |
| if echo "$COMMIT_MSG" | grep -qE '^[a-z]+\([^)]+\):'; then | |
| echo -e "${RED}β Scopes are not allowed in commit messages!${NC}" | |
| echo -e "${YELLOW}π Invalid:${NC} ${RED}feat(ci): something${NC}" | |
| echo -e "${YELLOW}π Valid:${NC} ${GREEN}ci: something${NC}" | |
| exit 1 | |
| fi | |
| # Check for scope usage (not allowed) | |
| if echo "$COMMIT_MSG" | grep -qE '^[a-z]+\([^)]+\):|^[^[:space:]]+ [a-z]+\([^)]+\):'; then | |
| echo -e "${RED}β Scopes are not allowed in commit messages!${NC}" | |
| echo -e "${YELLOW}π Invalid:${NC} ${RED}feat(ci): something${NC}" | |
| echo -e "${YELLOW}π Valid:${NC} ${GREEN}ci: something${NC}" | |
| exit 1 | |
| fi |
| # Check for emoji format: emoji type: description | ||
| if echo "$COMMIT_MSG" | grep -qE '^[^[:space:]]+ [a-z]+: .+'; then | ||
| HAS_EMOJI=true | ||
| HAS_TYPE=true | ||
| # Check for type-only format: type: description (will be auto-converted by prepare-commit-msg) | ||
| elif echo "$COMMIT_MSG" | grep -qE '^[a-z]+: .+'; then | ||
| HAS_TYPE=true | ||
| echo -e "${YELLOW}β οΈ Commit message missing emoji!${NC}" | ||
| echo -e "${YELLOW}π Your message:${NC} $COMMIT_MSG" | ||
| echo -e "${YELLOW}π This will be auto-converted by the prepare-commit-msg hook${NC}" | ||
| echo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
Policy mismatch with CI: local hook allows type-only but CI requires emoji
This will let local commits pass while CI fails (see .husky/ci-check-commits.sh which rejects type-only). Make commit-msg reject type-only to keep behavior consistent.
Apply:
-elif echo "$COMMIT_MSG" | grep -qE '^[a-z]+: .+'; then
- HAS_TYPE=true
- echo -e "${YELLOW}β οΈ Commit message missing emoji!${NC}"
- echo -e "${YELLOW}π Your message:${NC} $COMMIT_MSG"
- echo -e "${YELLOW}π This will be auto-converted by the prepare-commit-msg hook${NC}"
- echo
-else
+elif echo "$COMMIT_MSG" | grep -qE '^[a-z]+: .+'; then
+ echo -e "${RED}β Missing emoji! Required format: emoji type: description${NC}"
+ echo -e "${YELLOW}π‘ Example:${NC} β¨ feat: add new feature"
+ exit 1
+elseπ Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Check for emoji format: emoji type: description | |
| if echo "$COMMIT_MSG" | grep -qE '^[^[:space:]]+ [a-z]+: .+'; then | |
| HAS_EMOJI=true | |
| HAS_TYPE=true | |
| # Check for type-only format: type: description (will be auto-converted by prepare-commit-msg) | |
| elif echo "$COMMIT_MSG" | grep -qE '^[a-z]+: .+'; then | |
| HAS_TYPE=true | |
| echo -e "${YELLOW}β οΈ Commit message missing emoji!${NC}" | |
| echo -e "${YELLOW}π Your message:${NC} $COMMIT_MSG" | |
| echo -e "${YELLOW}π This will be auto-converted by the prepare-commit-msg hook${NC}" | |
| echo | |
| # Check for emoji format: emoji type: description | |
| if echo "$COMMIT_MSG" | grep -qE '^[^[:space:]]+ [a-z]+: .+'; then | |
| HAS_EMOJI=true | |
| HAS_TYPE=true | |
| # Check for type-only format: type: description (will be auto-converted by prepare-commit-msg) | |
| elif echo "$COMMIT_MSG" | grep -qE '^[a-z]+: .+'; then | |
| echo -e "${RED}β Missing emoji! Required format: emoji type: description${NC}" | |
| echo -e "${YELLOW}π‘ Example:${NC} β¨ feat: add new feature" | |
| exit 1 | |
| else | |
| # ... |
π€ Prompt for AI Agents
In .githooks/commit-msg around lines 91-101 the script currently treats "type:
description" as acceptable (sets HAS_TYPE=true and only warns), but CI requires
an emoji so local behavior must match CI; modify the elif branch that matches
'^[a-z]+: .+' to NOT set HAS_TYPE, print an error-level message that the commit
is missing an emoji (show the commit message and guidance), and exit with a
non-zero status (e.g., exit 1) so type-only commits are rejected locally just
like the CI hook.
| if [[ $COMMIT_SOURCE == "merge" ]] || [[ $COMMIT_SOURCE == "squash" ]] || [[ $COMMIT_SOURCE == "cherry-pick" ]]; then | ||
| exit 0 | ||
| fi | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert commits blocked
git revert messages ("Revert ...") wonβt match type format and this hook exits 1. Either skip or transform to βͺ revert:.
-if [[ $COMMIT_SOURCE == "merge" ]] || [[ $COMMIT_SOURCE == "squash" ]] || [[ $COMMIT_SOURCE == "cherry-pick" ]]; then
+if [[ $COMMIT_SOURCE == "merge" ]] || [[ $COMMIT_SOURCE == "squash" ]] || [[ $COMMIT_SOURCE == "cherry-pick" ]]; then
exit 0
fi
...
-else
+else
+ # Allow native revert messages
+ if echo "$COMMIT_MSG" | grep -qE '^Revert "; then
+ echo -e "${BLUE}βΉοΈ Detected native revert commit; leaving message unchanged${NC}"
+ exit 0
+ fi
echo -e "${YELLOW}β οΈ No valid tag found, manual tag required${NC}"If you prefer auto-transform, I can provide a patch that rewrites to βͺ revert: ....
Also applies to: 145-151
π€ Prompt for AI Agents
In .githooks/prepare-commit-msg around lines 23-26 (and similarly 145-151), the
hook currently skips merge/squash/cherry-pick but blocks git revert commits;
update the logic to detect COMMIT_SOURCE == "revert" and either exit 0 to allow
revert messages, or automatically transform the commit message: read the
commit-msg file ($1), detect a first-line starting with "Revert" and replace it
with a standardized emoji prefix and subject like "βͺ revert: <original subject>"
(preserve rest of message/body), then write the file back; ensure the change is
applied in both places the logic appears.
| # Create hooks directory if it doesn't exist | ||
| mkdir -p .git/hooks | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
Honor core.hooksPath
If users set core.hooksPath, .git/hooks isnβt used. Install to the configured path.
-# Create hooks directory if it doesn't exist
-mkdir -p .git/hooks
+HOOKS_DIR="$(git config --get core.hooksPath || echo "$(git rev-parse --git-dir)/hooks")"
+mkdir -p "$HOOKS_DIR"And update subsequent paths to "$HOOKS_DIR".
π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Create hooks directory if it doesn't exist | |
| mkdir -p .git/hooks | |
| # Determine where Git expects its hooks (honor core.hooksPath if set) | |
| HOOKS_DIR="$(git config --get core.hooksPath || echo "$(git rev-parse --git-dir)/hooks")" | |
| mkdir -p "$HOOKS_DIR" |
π€ Prompt for AI Agents
In scripts/install-hooks.sh around lines 23 to 25, the script unconditionally
creates .git/hooks but ignores a user-configured core.hooksPath; change the
script to query git config --get core.hooksPath and set HOOKS_DIR to that value
if present, otherwise default to .git/hooks, then create the directory using
"$HOOKS_DIR" and update all subsequent references/paths in the script to use
"$HOOKS_DIR" instead of the hardcoded .git/hooks.
π Description
π Type of Change
π Changes Made
π§ͺ Testing
Test Results
π Documentation
π Related Issues
Fixes #
Closes #
Related to #
πΈ Screenshots/Examples
β Checklist
π― Focus Areas for Review
π¨ Breaking Changes
π Additional Notes
Please ensure all checks pass before requesting review
Summary by CodeRabbit
New Features
Documentation