Skip to content

Feat/commitlint setup#66

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

Feat/commitlint setup#66
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

  • Documentation

    • Updated installation and setup instructions with Node.js prerequisites and streamlined configuration process
    • Added new "Join Our Community" section to README
  • Chores

    • Updated commit validation and Git workflow infrastructure
    • Simplified development tooling configuration

@coderabbitai
Copy link

coderabbitai bot commented Mar 7, 2026

Walkthrough

The changes migrate from npm-managed Git hooks (Husky, lint-staged) to native Git hooks using core.hooksPath, remove package.json and associated npm dependencies, consolidate commit validation via commitlint in local hooks and CI/CD, and update documentation to reflect the new setup process.

Changes

Cohort / File(s) Summary
Git Hooks Reconfiguration
.git-hooks/commit-msg, .husky/commit-msg, .husky/pre-commit
New git-hooks/commit-msg script added to validate commit messages via commitlint. Husky hooks content removed (commit-msg validation and pre-commit lint-staged execution disabled).
CI/CD Workflow
.github/workflows/commit-lint.yml
Job renamed to commit-check; checkout step simplified; Node.js updated to version 20; npm-based commitlint replaced with shell-based per-commit validation loop using npx commitlint with error handling.
Linting Configuration
commitlint.config.js
Removed extends from @commitlint/config-conventional; expanded and restructured rules object to include subject-empty, subject-full-stop, type-case, type-empty, type-enum alongside existing rules.
Project Metadata and Tooling
package.json
Entire file removed, eliminating all project metadata, npm scripts, and devDependencies including commitizen, cz-conventional-changelog, commitlint, husky, and lint-staged.
Documentation
README.md
Added Node.js to prerequisites; replaced manual hook setup with git config core.hooksPath; added installation, build, and runtime steps; removed "Setting Up Commit Hooks" section; added "Join Our Community" section.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 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 'Feat/commitlint setup' directly relates to the main changes in the PR, which center on establishing commitlint validation infrastructure across multiple configuration files and workflows.
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

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.

@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)
.github/workflows/commit-lint.yml (1)

20-31: Per-commit validation loop is well-implemented.

The use of set -eo pipefail ensures robust error handling, and excluding merge commits with --no-merges is appropriate. The graceful exit when no commits are found prevents false failures.

One edge case to consider: if the base branch was force-pushed after the PR was created, github.event.pull_request.base.sha may reference a commit that no longer exists, causing git log to fail. This is uncommon but could occur in active repositories.

🛠️ Optional: Add fallback for missing base SHA
       - name: Validate commit messages
         run: |
           set -eo pipefail
+          base_sha="${{ github.event.pull_request.base.sha }}"
+          if ! git cat-file -e "$base_sha" 2>/dev/null; then
+            echo "Base SHA not found, using merge-base instead"
+            base_sha=$(git merge-base origin/${{ github.base_ref }} ${{ github.event.pull_request.head.sha }})
+          fi
-          commits=$(git log --no-merges --pretty=format:"%H" "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}")
+          commits=$(git log --no-merges --pretty=format:"%H" "$base_sha..${{ github.event.pull_request.head.sha }}")
           if [ -z "$commits" ]; then
             echo "No commits to validate"
             exit 0
           fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/commit-lint.yml around lines 20 - 31, Handle the edge case
where github.event.pull_request.base.sha no longer exists by detecting failure
before building commits: check whether the base SHA resolves (e.g., with git
rev-parse or testing the exit status of git log) and if it fails, fall back to a
safe alternative such as fetching the base branch ref
(github.event.pull_request.base.ref) from the remote and using that ref or using
git merge-base to compute a valid range; keep the rest of the loop that sets
commits and iterates over sha unchanged so variables like commits and the
validation loop using npx `@commitlint/cli`@20.4.3 continue to work.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.github/workflows/commit-lint.yml:
- Around line 20-31: Handle the edge case where
github.event.pull_request.base.sha no longer exists by detecting failure before
building commits: check whether the base SHA resolves (e.g., with git rev-parse
or testing the exit status of git log) and if it fails, fall back to a safe
alternative such as fetching the base branch ref
(github.event.pull_request.base.ref) from the remote and using that ref or using
git merge-base to compute a valid range; keep the rest of the loop that sets
commits and iterates over sha unchanged so variables like commits and the
validation loop using npx `@commitlint/cli`@20.4.3 continue to work.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7ebfc8a4-ab2f-44da-b2a1-9c33e188b90d

📥 Commits

Reviewing files that changed from the base of the PR and between 4ffd8c3 and 4e09248.

⛔ 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/pre-commit
  • package.json
  • .husky/commit-msg

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