chore(commitlint): add commit-msg hook and workflow validation#118
chore(commitlint): add commit-msg hook and workflow validation#118DurgaPrasad-54 wants to merge 2 commits intoPSMRI:mainfrom
Conversation
📝 WalkthroughWalkthroughReplaces Husky hooks with a custom Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer (git commit)
participant Git as Git Hooks (.git-hooks/commit-msg)
participant CL as Commitlint (`@commitlint/cli`)
participant CI as CI Workflow (.github/workflows)
Dev->>Git: git commit (message)
Git->>CL: npx `@commitlint/cli` --edit "$1"
CL-->>Git: pass / fail
Git-->>Dev: allow commit / block commit
Note over CI,CL: On push/PR
CI->>CI: enumerate commits (base..head)
CI->>CL: validate each commit message
CL-->>CI: pass / fail
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/commit-lint.yml:
- Around line 22-29: Replace the temp-file + --edit approach with piping and
handle empty commit ranges explicitly: check the commits variable
(commits="$(git log ... )") and if it's empty print a message and exit 0; inside
the for loop stream each commit message with git log -1 --pretty=format:"%B"
"$sha" | npx --yes `@commitlint/cli`@20.4.3 --stdin (drop the tmp variable and the
--edit flag and remove rm "$tmp"), which avoids temp-file leaks and ensures
commitlint reads from stdin.
In `@README.md`:
- Line 20: Replace the nonstandard "Node Js" entry in the README with the
official casing "Node.js" by updating the text string "Node Js" to "Node.js" so
the documentation uses the correct and consistent naming.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2892e38a-7ee2-4b2a-8883-a0eb2cf82411
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (7)
.git-hooks/commit-msg.github/workflows/commit-lint.yml.husky/commit-msg.husky/pre-commitREADME.mdcommitlint.config.jspackage.json
💤 Files with no reviewable changes (3)
- .husky/commit-msg
- .husky/pre-commit
- package.json
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
README.md (1)
26-28: Document the expected commit format next to the hook setup.These steps enable the hook, but the README no longer shows what a valid commit message looks like. A short example here would save contributors from discovering the convention only after the hook rejects their commit.
📝 Suggested addition
2. Enable git hooks (run once after cloning): - Run the command `git config core.hooksPath .git-hooks`. + - Commit messages must follow the project convention, for example: + - `feat(inventory): add stock transfer endpoint` + - `fix(ci): validate each PR commit message` 3. Install the dependencies `mvn clean install`🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@README.md` around lines 26 - 28, Add a short description and example of the required commit message format immediately after the hook setup step (the step containing the command `git config core.hooksPath .git-hooks`), e.g., state the convention used (Conventional Commits or custom format), a one-line pattern (like "type(scope): short summary") and a 1–2 line example commit message so contributors know what a valid commit looks like before the hook rejects it.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@README.md`:
- Around line 26-28: Add a short description and example of the required commit
message format immediately after the hook setup step (the step containing the
command `git config core.hooksPath .git-hooks`), e.g., state the convention used
(Conventional Commits or custom format), a one-line pattern (like "type(scope):
short summary") and a 1–2 line example commit message so contributors know what
a valid commit looks like before the hook rejects it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b495fa30-4281-4898-b28d-188ff35f1823
📒 Files selected for processing (2)
.github/workflows/commit-lint.ymlREADME.md



📋 Description
JIRA ID:
Add the commit message validation setup by defining the commit rules directly in commitlint.config.js instead of extending @commitlint/config-conventional.
✅ Type of Change
Summary by CodeRabbit
Chores
Documentation