chore(commitlint): add commit-msg hook and workflow validation#122
chore(commitlint): add commit-msg hook and workflow validation#122DurgaPrasad-54 wants to merge 3 commits intoPSMRI:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughReplaces Husky hooks with a native Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer (local)
participant Git as Git
participant GH as GitHub Actions Runner
participant CL as commitlint (npx)
Note over Dev,Git: Local commit flow (native hooks)
Dev->>Git: git commit
Git->>Git: run .git-hooks/commit-msg (shell + set -e)
Git->>CL: npx `@commitlint/cli`@20.4.3 --edit <msgfile>
CL-->>Git: pass / fail
Git-->>Dev: commit accepted / aborted
Note over GH,CL: PR validation flow
GH->>Git: fetch base..head commits
loop for each commit sha
GH->>Git: git show --format=%B <sha>
GH->>CL: npx `@commitlint/cli`@20.4.3 --edit <tempfile>
CL-->>GH: pass / fail
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 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)
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
🧹 Nitpick comments (1)
.git-hooks/commit-msg (1)
3-3: Consider pinning the commitlint CLI version for consistency with the CI workflow.The CI workflow uses
@commitlint/cli@20.4.3but this hook uses an unpinned version. This could lead to different validation behavior locally vs. in CI if a breaking change is released.Proposed fix
-npx --yes `@commitlint/cli` --edit "$1" +npx --yes `@commitlint/cli`@20.4.3 --edit "$1"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.git-hooks/commit-msg at line 3, The commit hook invokes the commitlint CLI without a fixed version; update the invocation in .git-hooks/commit-msg so it pins the same version used in CI (e.g., replace "@commitlint/cli" with "@commitlint/cli@20.4.3") to ensure local and CI validation remain consistent when running npx --yes `@commitlint/cli` --edit "$1" (update that exact command).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.git-hooks/commit-msg:
- Around line 1-3: The commit-msg hook currently runs npx but doesn't enable
errexit, so failures may be ignored; modify the .git-hooks/commit-msg script
(the shebang + the existing npx invocation) to enable strict failure handling by
adding set -e immediately after the #!/bin/sh line so that the npx --yes
`@commitlint/cli` --edit "$1" command causes the hook to exit non‑zero when
commitlint rejects a message.
In @.github/workflows/commit-lint.yml:
- Around line 20-31: Replace the piped while-subshell approach with a
non-subshell loop and ensure failures propagate and temp files are always
cleaned up: add set -eo pipefail, capture commits into a variable (commits=$(git
log --no-merges --pretty=format:"%H" "${{ github.event.pull_request.base.sha
}}..${{ github.event.pull_request.head.sha }}")), iterate with for sha in
$commits; do ... done, create tmp via mktemp, run git log -1
--pretty=format:"%B" "$sha" > "$tmp" and npx --yes `@commitlint/cli`@20.4.3 --edit
"$tmp", and remove the tmp with rm "$tmp"; also register a trap (trap 'rm -f
"$tmp"' EXIT) before the loop to guarantee cleanup if commitlint fails.
---
Nitpick comments:
In @.git-hooks/commit-msg:
- Line 3: The commit hook invokes the commitlint CLI without a fixed version;
update the invocation in .git-hooks/commit-msg so it pins the same version used
in CI (e.g., replace "@commitlint/cli" with "@commitlint/cli@20.4.3") to ensure
local and CI validation remain consistent when running npx --yes `@commitlint/cli`
--edit "$1" (update that exact command).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 014bf00f-fa18-4a04-aad4-4d6814121749
⛔ 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)
- package.json
- .husky/pre-commit
- .husky/commit-msg
|



📋 Description
JIRA ID:
Updated the commit message validation setup by defining the commit rules directly in commitlint.config.js instead of extending @commitlint/config-conventional.
✅ Type of Change
ℹ️ Additional Information
Please describe how the changes were tested, and include any relevant screenshots, logs, or other information that provides additional context.
Summary by CodeRabbit
Chores
Documentation
Refactor