Skip to content

git_commit_subject_matches

Each commit’s subject line (the first line of its message) must match the matches: regex — the subject-grammar member of the commit family. Enforces a prefix + shape convention like go / Gerrit’s pkg/path: lowercase summary, node’s subsystem: description, or conventional-commit types. The regex is anchored to the subject alone (so ^…$ describes the first line exactly), unlike git_commit_message’s pattern: which matches the whole subject + body; for a subject-length cap use git_commit_message’s subject_max_length:. Shares the commit-validation family’s since: / include_merges: semantics and failure modes (HEAD-only when since: is unset, <since>..HEAD when set; silent outside a git repo; a bad since: ref hard-fails with a shallow-clone hint).

OptionTypeRequiredDefaultDescription
include_mergesbooleanfalseWhen validating a range (since: set), include merge commits. Has no effect when since: is unset; combining include_merges: true with no since: is a load-time error.
matchesstringyesRust-regex the commit subject (first line of the message) must match.
sincestringnullGit ref to use as the base of the commit range. When set, validates every commit in <since>..HEAD instead of just HEAD. Use the canonical {{env.X}} interpolation to pass a SHA via an env var, e.g. since: "{{env.ALINT_BASE_SHA | default('origin/main')}}".

Plus the common level, id, and when fields. This rule analyses the whole repository, so it takes no paths. This table is generated from the JSON Schema; option types and defaults are authoritative.

A commit subject that breaks the required grammar

Section titled “A commit subject that breaks the required grammar”

The rule fires on this repository:

README.md
README.md
# demo

With this .alint.yml:

version: 1
rules:
- id: subject-grammar
kind: git_commit_subject_matches
matches: '^[a-z0-9_/.-]+: [a-z].*$'
level: error

committed with this history (oldest first):

2024-01-15T09:00:00+00:00 WIP: Capitalised and the wrong shape

alint check reports:

Terminal window
--- Repository-level -----------------------------------------------------------
x error subject-grammar
commit e103bea: subject does not match `^[a-z0-9_/.-]+: [a-z].*$`
(subject: "WIP: Capitalised and the wrong shape")
Summary (1 violation):
x 1 error
0 passing * 1 failing

A commit subject that follows the component: summary grammar

Section titled “A commit subject that follows the component: summary grammar”

This repository is compliant:

README.md
README.md
# demo

With this .alint.yml:

version: 1
rules:
- id: subject-grammar
kind: git_commit_subject_matches
matches: '^[a-z0-9_/.-]+: [a-z].*$'
level: error

committed with this history (oldest first):

pkg/net: add a thing

alint check reports:

Terminal window
v All 1 rule(s) passed.