Conversation
📝 WalkthroughWalkthroughThis pull request implements Conventional Commits enforcement across the repository by integrating Husky.NET with CommitLint.Net for local and CI validation. Changes include adding a GitHub Actions workflow, Git hooks, tool configuration, and commit message validation rules, along with documentation updates. Changes
Sequence DiagramsequenceDiagram
participant Dev as Developer
participant Git as Git Client
participant Husky as Husky.NET Hook
participant Lint as CommitLint.Net
participant Config as commit-message-config.json
participant GH as GitHub Actions
Dev->>Git: git commit -m "feat: new feature"
Git->>Husky: Trigger commit-msg hook
Husky->>Lint: Run commit-lint with commit file
Lint->>Config: Load validation rules
Config-->>Lint: Return config (Conventional Commits, max 90 chars, etc.)
alt Valid Message
Lint-->>Husky: Exit 0 (success)
Husky-->>Git: Proceed with commit
Git-->>Dev: Commit created
else Invalid Message
Lint-->>Husky: Exit non-zero (failure)
Husky-->>Git: Block commit
Git-->>Dev: Commit rejected
end
Dev->>GH: Push to master / Create PR
GH->>Lint: Run commit-message.yml workflow
Lint->>Config: Validate all commits
Config-->>Lint: Apply rules
Lint-->>GH: Report validation results
GH-->>Dev: Workflow status
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #305 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 39 39
Lines 424 424
Branches 55 55
=========================================
Hits 424 424
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
.github/workflows/commit-message.yml (1)
43-45: Lint all pushed commits onpush, not only HEAD.Line 44 checks only the latest commit, so earlier commits in a multi-commit push can bypass this workflow.
♻️ Suggested update
- } else { - $commits = git log -1 --pretty="%H" + } elseif ("${{ github.event.before }}" -and "${{ github.event.before }}" -ne "0000000000000000000000000000000000000000") { + $commits = git log --no-merges --pretty="%H" "${{ github.event.before }}..${{ github.sha }}" + } else { + $commits = git log -1 --pretty="%H" "${{ github.sha }}" }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/commit-message.yml around lines 43 - 45, The workflow only captures HEAD by setting $commits via git log -1 --pretty="%H"; update the $commits assignment to list all commits in the push (e.g., replace the git log -1 command with a rev-list over the pushed range) so every pushed commit is linted — for example set $commits using git rev-list --no-merges --pretty=format:%H ${GITHUB_EVENT_BEFORE}..${GITHUB_SHA} (replace the existing git log -1 --pretty="%H" invocation).
🤖 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-message.yml:
- Line 1: Normalize line endings in the workflow whose name is "📝 Commit
Message Lint" to LF (\n) so YAMLlint stops reporting CRLF; convert the file's
line endings from CRLF to LF (e.g., via your editor, git config
core.autocrlf=false and re-save, or run dos2unix) and commit the change, and
optionally add/update a .gitattributes entry to enforce LF for YAML files to
prevent future regressions.
- Around line 1-49: This change adds a new GitHub Actions workflow
(commit-message.yml / "📝 Commit Message Lint") which requires explicit
maintainer approval before merging; update the PR to request that explicit
approval from a repository maintainer (add a clear note in the PR description
that this modifies a workflow, request the specific approver(s) or team, and/or
add the repository's "workflow change" label), and do not merge the branch until
a maintainer has reviewed and explicitly approved the workflow change.
In `@commit-message-config.json`:
- Around line 22-26: The current config disables scope enforcement via
scopes.enabled and CommitLint.Net v0.8.0 cannot require scope presence; to fix,
add a custom commit-msg validation that enforces the "<type>(scope):
<description>" pattern (e.g., a small script run by the commit-msg hook that
checks for a scope between parentheses), or replace CommitLint.Net with a linter
that supports required scopes, or patch CommitLint.Net to validate presence of
scope; update the repo hooks to run that script and remove/ignore scopes.enabled
so the new validator enforces scope presence.
---
Nitpick comments:
In @.github/workflows/commit-message.yml:
- Around line 43-45: The workflow only captures HEAD by setting $commits via git
log -1 --pretty="%H"; update the $commits assignment to list all commits in the
push (e.g., replace the git log -1 command with a rev-list over the pushed
range) so every pushed commit is linted — for example set $commits using git
rev-list --no-merges --pretty=format:%H ${GITHUB_EVENT_BEFORE}..${GITHUB_SHA}
(replace the existing git log -1 --pretty="%H" invocation).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 902c7d8a-2ae1-4976-aad3-65a101bf1b5e
📒 Files selected for processing (8)
.backlog/tasks/task-3 - Enforce-Conventional-Commits.md.github/workflows/commit-message.yml.husky/commit-msg.husky/task-runner.jsonAGENTS.mdCONTRIBUTING.mdcommit-message-config.jsondotnet-tools.json
| @@ -0,0 +1,49 @@ | |||
| name: '📝 Commit Message Lint' | |||
There was a problem hiding this comment.
Normalize to LF line endings to satisfy YAMLlint.
Static analysis reports wrong newline characters; convert this file to \n line endings to prevent lint failures.
🧰 Tools
🪛 YAMLlint (1.38.0)
[error] 1-1: wrong new line character: expected \n
(new-lines)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/commit-message.yml at line 1, Normalize line endings in
the workflow whose name is "📝 Commit Message Lint" to LF (\n) so YAMLlint stops
reporting CRLF; convert the file's line endings from CRLF to LF (e.g., via your
editor, git config core.autocrlf=false and re-save, or run dos2unix) and commit
the change, and optionally add/update a .gitattributes entry to enforce LF for
YAML files to prevent future regressions.
| name: '📝 Commit Message Lint' | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| push: | ||
| branches: | ||
| - 'master' | ||
| workflow_dispatch: | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: pwsh | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: windows-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: 📥 checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: 🛠️ setup .NET | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: 8.0.x | ||
|
|
||
| - name: 📦 restore local tools | ||
| run: dotnet tool restore | ||
|
|
||
| - name: ✅ lint commit messages | ||
| run: | | ||
| $messagePath = Join-Path $env:RUNNER_TEMP "commit-message.txt" | ||
| if ("${{ github.event_name }}" -eq "pull_request") { | ||
| $commits = git log --no-merges --pretty="%H" "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" | ||
| } else { | ||
| $commits = git log -1 --pretty="%H" | ||
| } | ||
| foreach ($sha in ($commits -split "`n" | Where-Object { $_ -ne "" })) { | ||
| git log -1 --pretty="%B" $sha | Out-File -FilePath $messagePath -Encoding utf8 | ||
| dotnet commit-lint --commit-file $messagePath --commit-message-config-file commit-message-config.json | ||
| } |
There was a problem hiding this comment.
Workflow-file changes need explicit maintainer approval.
This PR adds a new workflow under .github/workflows/, which is gated by repository policy and should be explicitly approved before merge.
As per coding guidelines: Changes to .github/workflows/ files require explicit approval.
🧰 Tools
🪛 YAMLlint (1.38.0)
[error] 1-1: wrong new line character: expected \n
(new-lines)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/commit-message.yml around lines 1 - 49, This change adds a
new GitHub Actions workflow (commit-message.yml / "📝 Commit Message Lint")
which requires explicit maintainer approval before merging; update the PR to
request that explicit approval from a repository maintainer (add a clear note in
the PR description that this modifies a workflow, request the specific
approver(s) or team, and/or add the repository's "workflow change" label), and
do not merge the branch until a maintainer has reviewed and explicitly approved
the workflow change.
| "scopes": { | ||
| "enabled": false, | ||
| "global": [], | ||
| "per-type": {} | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
In CommitLint.Net v0.8.0, what configuration enforces a required scope in Conventional Commits? I need to reject messages like "docs: update readme" and accept "docs(contributing): update readme".
💡 Result:
CommitLint.Net v0.8.0 does not have a configuration option to require that a scope be present.
Even with conventional-commit.scopes.enabled: true, the scope rules explicitly pass when no (scope) is found (“No scope found.”), so docs: update readme will not be rejected. (github.com)
So, in v0.8.0 you can only validate scope format (when present) and restrict allowed scope values (when present), but you can’t enforce “scope required” via config; you’d need a custom hook/regex check or a fork/patch. (nuget.org)
Citations:
- 1: https://github.com/tomwis/CommitLint.Net/blob/main/src/CommitLint.Net/Rules/AllowedScopesRule.cs
- 2: https://www.nuget.org/packages/CommitLint.Net/0.8.0
Scopes cannot be enforced with the current CommitLint.Net v0.8.0 configuration.
Line 23 disables scopes (scopes.enabled: false), allowing messages like docs: ... to pass. However, verification reveals CommitLint.Net v0.8.0 has no built-in configuration option to require scopes; even if enabled, the tool only validates scope format when present but does not enforce scope presence itself. To align with the repo convention (<type>(scope): <description>), you'll need a custom validation hook, a different linting tool, or a patch to CommitLint.Net.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@commit-message-config.json` around lines 22 - 26, The current config disables
scope enforcement via scopes.enabled and CommitLint.Net v0.8.0 cannot require
scope presence; to fix, add a custom commit-msg validation that enforces the
"<type>(scope): <description>" pattern (e.g., a small script run by the
commit-msg hook that checks for a scope between parentheses), or replace
CommitLint.Net with a linter that supports required scopes, or patch
CommitLint.Net to validate presence of scope; update the repo hooks to run that
script and remove/ignore scopes.enabled so the new validator enforces scope
presence.
Summary
Enforce conventional commits
Checklist
type(scope): description)dotnet build src/Objectivity.AutoFixture.XUnit2.AutoMock.slnpasses with no warningsdotnet test src/Objectivity.AutoFixture.XUnit2.AutoMock.slnpasses on all framework slices[SuppressMessage]without a justification comment// TODO:comments added — open a GitHub issue insteadSummary by CodeRabbit
Release Notes
New Features
Documentation