chore(commitlint): add commit-msg hook and workflow validation#210
chore(commitlint): add commit-msg hook and workflow validation#210DurgaPrasad-54 wants to merge 2 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)
📝 WalkthroughWalkthroughAdds commit message linting: a local git commit hook, a commitlint configuration, a GitHub Actions workflow to validate PR commit messages, and README instructions to enable the hooks. Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer (local)
participant Repo as Repository / PR
participant GH as GitHub Actions Runner
participant CL as commitlint (via npx)
Dev->>Repo: Open / update Pull Request
Note right of Repo: PR event triggers workflow
Repo->>GH: Start "Commit Message Check" workflow
GH->>GH: checkout + setup Node.js v20
GH->>Repo: list commits in PR (exclude merge commits)
loop for each commit
GH->>GH: write commit message to temp file
GH->>CL: run `npx `@commitlint/cli`@20.4.3 --edit temp-file`
CL-->>GH: exit status (pass/fail)
end
GH-->>Repo: report workflow result (success/failure)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 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: 1
🧹 Nitpick comments (1)
.git-hooks/commit-msg (1)
4-4: Avoid a registry fetch in the commit path.This one-off
npxinstall makes local commits depend on npm registry availability and duplicates the pinned CLI version in CI. Prefer declaring@commitlint/clionce in repo tooling and invoking the local binary from both the hook and workflow.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.git-hooks/commit-msg at line 4, Replace the one-off npx invocation in the commit hook ("npx --yes `@commitlint/cli`@20.4.3 --edit \"$1\"") with a call to the repo-local commitlint install: declare `@commitlint/cli` as a devDependency and expose a script or rely on the local binary, then update the commit hook to invoke that local binary (or run the package script) with the same --edit "$1" argument so commits no longer perform an npm registry fetch.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Around line 62-64: The README's prerequisites block is missing Node.js/npm
which causes the commit-msg hook (which uses npx to run commitlint) to fail with
"npx: not found"; update the prerequisites section to list Node.js (and npm) as
required tools and add a short note that the git hook setup (see "Setting Up
Commit Hooks" and the command `git config core.hooksPath .git-hooks`) relies on
npx/Node.js so contributors should install Node.js/npm before enabling hooks.
---
Nitpick comments:
In @.git-hooks/commit-msg:
- Line 4: Replace the one-off npx invocation in the commit hook ("npx --yes
`@commitlint/cli`@20.4.3 --edit \"$1\"") with a call to the repo-local commitlint
install: declare `@commitlint/cli` as a devDependency and expose a script or rely
on the local binary, then update the commit hook to invoke that local binary (or
run the package script) with the same --edit "$1" argument so commits no longer
perform an npm registry fetch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b0abccc0-2f0b-4de8-889a-0e97a331e68a
📒 Files selected for processing (4)
.git-hooks/commit-msg.github/workflows/commit-lint.ymlREADME.mdcommitlint.config.js
📋 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