Git commit conventional scope linter.
Lint changed files against configured scope. Similar to CODEOWNERS. Useful if your dev-flow requires strict scoped file changes control over CI process.
docker pull thumbrise/commitlint-scope:latest-alpinehttps://github.com/thumbrise/commitlint-scope/releases
No CGO
Binaries are statically compiled (CGO_ENABLED=0) and work without external dependencies on Linux, macOS, and Windows.Go to your repository root.
cd /path/to/your/repo/commitlint-scope run --from main --to featuredocker run --rm -v "$(pwd):/repo" -w /repo thumbrise/commitlint-scope:latest-alpine run --from main --to feature --verboseGenerate .commitlint-scope.yaml file.
commitlint-scope init#$schema: https://github.com/thumbrise/commitlint-scope/blob/main/docs/schema/config.v3.json
# Scope parsing customization. Not required, if you follow common conventional header. In example: 'type!(scope): subject'
#scopeRegex: ^[a-z]+(?:\((?P<scope>[^)]+)\))?!?:\s
# Patterns list: each item specifies a list of scopes and the corresponding file glob patterns.
patterns:
- scopes: ["auth"]
files: ["services/auth/**"]
- scopes: ["migrations", "sql"]
files: ["database/migrations/*.sql"]
- scopes: ["frontend", "assets"]
files: ["**/assets/**", "**/frontend/**"]
- scopes: ["docs", "md"]
files: ["**/*.md"]
- scopes: ["some.dot.scope", "any-anotherscope"]
files: ["**/rail.v1.json"]Without a configuration file, each scope is used as a glob pattern by appending /. For example, a commit with scope auth will check if any changed file matches auth/. This behaviour keeps things simple for repositories where directory names mirror commit scopes.
For example:
feat(auth): Some subject
Linter will compare changed files against glob pattern auth/**.
name: Lint Commit Scopes
on:
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository (full history)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Lint commit scopes
run: |
docker run --rm \
-v "${{ github.workspace }}:/repo" \
-w /repo \
thumbrise/commitlint-scope:latest-alpine \
run \
--from ${{ github.event.pull_request.base.sha }} \
--to ${{ github.event.pull_request.head.sha }} \
--verbosecommitlint:
image: thumbrise/commitlint-scope:latest-alpine
stage: test
variables:
GIT_DEPTH: 0
script:
- commitlint-scope run --from $CI_MERGE_REQUEST_DIFF_BASE_SHA --to $CI_COMMIT_SHA
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"pipelines:
pull-requests:
'**':
- step:
name: Lint commit scopes
image: thumbrise/commitlint-scope:latest-alpine # For production - use specific version
script:
- git fetch --unshallow || true
- commitlint-scope run --from $BITBUCKET_PR_DESTINATION_BRANCH --to $BITBUCKET_COMMIT- Always do a full clone (
fetch-depth: 0or equivalent) sogit rev-listcan find all commits. - For shallow clones, use
git fetch --unshallowor ensure the required commit range is available, otherwisegit rev-listwill fail. - If your CI doesn't provide base/target commit variables, specify the SHAs manually.
- The image already includes safe directory configuration (
safe.directory '*') for smooth operation.
https://github.com/thumbrise/commitlint-scope/blob/main/docs/schema/config.v3.json
Apache 2.0