Skip to content

chore(commitlint): add commit-msg hook and workflow validation#118

Open
DurgaPrasad-54 wants to merge 2 commits intoPSMRI:mainfrom
DurgaPrasad-54:feat/commitlint-setup
Open

chore(commitlint): add commit-msg hook and workflow validation#118
DurgaPrasad-54 wants to merge 2 commits intoPSMRI:mainfrom
DurgaPrasad-54:feat/commitlint-setup

Conversation

@DurgaPrasad-54
Copy link
Contributor

@DurgaPrasad-54 DurgaPrasad-54 commented Mar 7, 2026

📋 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

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • New feature (non-breaking change which adds functionality)
  • 🔥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🛠 Refactor (change that is neither a fix nor a new feature)
  • ⚙️ Config change (configuration file or build script updates)
  • 📚 Documentation (updates to docs or readme)
  • 🧪 Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • 🚀 Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

Summary by CodeRabbit

  • Chores

    • Reworked commit message validation: added a repository-level commit hook and moved CI to per-commit message checks.
    • Removed prior hook runner and pre-commit lint-staged invocation; project manifest and commit tooling config were deleted.
    • CI workflow renamed and updated, including a newer Node.js runtime.
  • Documentation

    • Updated getting-started instructions to include Node.js prerequisite and steps to enable repository git hooks; removed prior commit-hooks setup section.

@coderabbitai
Copy link

coderabbitai bot commented Mar 7, 2026

📝 Walkthrough

Walkthrough

Replaces Husky hooks with a custom .git-hooks/commit-msg script that runs commitlint, removes package.json and Husky lint-staged hooks, updates CI workflow to per-commit commitlint checks, removes extends from commitlint config, and updates README git-hooks/install steps. (49 words)

Changes

Cohort / File(s) Summary
Git hooks
.git-hooks/commit-msg, .husky/commit-msg, .husky/pre-commit
Added new .git-hooks/commit-msg script invoking @commitlint/cli@20.4.3; removed Husky commit-msg and pre-commit hooks (lint-staged invocation deleted).
CI workflow
.github/workflows/commit-lint.yml
Renamed workflow/job, simplified checkout, bumped Node.js to 20, removed separate install step, and changed commitlint to iterate and validate each commit between base/head.
Commitlint config
commitlint.config.js
Removed the extends reference to @commitlint/config-conventional; existing custom rules retained.
Project manifest & docs
package.json, README.md
Deleted package.json; updated README to add Node.js prereq and git hooks enablement, removed previous "Setting Up Commit Hooks" section.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped from Husky's den into a tidy new nook,
A tiny hook now checks each line in every commit book.
Docs trimmed and Node set right, the CI scans each clue,
I nibble through the changes — neat, concise, and true! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding a commit-msg hook (.git-hooks/commit-msg) and workflow validation (.github/workflows/commit-lint.yml), which aligns with the core objectives and modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between af64c6c and 5abcf1c.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • .git-hooks/commit-msg
  • .github/workflows/commit-lint.yml
  • .husky/commit-msg
  • .husky/pre-commit
  • README.md
  • commitlint.config.js
  • package.json
💤 Files with no reviewable changes (3)
  • .husky/commit-msg
  • .husky/pre-commit
  • package.json

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 7, 2026

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5abcf1c and 326897f.

📒 Files selected for processing (2)
  • .github/workflows/commit-lint.yml
  • README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant