Conversation
WalkthroughThe changes migrate from npm-managed Git hooks (Husky, lint-staged) to native Git hooks using Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 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.
🧹 Nitpick comments (1)
.github/workflows/commit-lint.yml (1)
20-31: Per-commit validation loop is well-implemented.The use of
set -eo pipefailensures robust error handling, and excluding merge commits with--no-mergesis 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.shamay reference a commit that no longer exists, causinggit logto 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
⛔ 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/pre-commit
- package.json
- .husky/commit-msg



📋 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
Documentation
Chores