Commit grammar
Slots
The fields that declare a commit header.
A header is a prefix of slots, one space, and a description.
feat(api)!: add an endpoint
└──┘└───┘│└ separator
│ │ └ modifiers
│ └ scope
└ keywords[[commit.slots]] lists the slots in header order.
[[commit.slots]]
name = "keywords"
kind = "word"
values = ["feat", "fix"]
required = true
[[commit.slots]]
name = "scope"
delimiters = ["(", ")"]
[[commit.slots]]
name = "separator"
kind = "symbol"
values = [":"]
required = true| Header | Result |
|---|---|
feat: x | Valid |
fix(parser): x | Valid |
chore: x | Invalid: chore not in values |
feat x | Invalid: no separator |
Fields
| Field | Type | Default |
|---|---|---|
name | string | none, required |
kind | "word", "symbols" or "symbol" | none |
delimiters | two characters, such as ["(", ")"] | none |
one-of | array of option slots; see One of | none |
values | "any", or an array of spellings | "any" |
required | boolean | false |
gap | boolean; see Spacing | false |
tight | boolean; see Spacing | false |
- A slot has exactly one of
kind,delimitersorone-of. nameappears in messages and is the key for merging.
Kinds
| Kind | Matches |
|---|---|
word | A run of Unicode letters, digits and _ |
symbols | A run of visible characters other than word characters |
symbol | One visible character other than a word character |
An unrestricted symbols run stops before any delimiter opener in the
grammar and before the separator that follows it. With an unrestricted
separator, the last symbol of the run is the separator.
Delimited slots
values | Contents |
|---|---|
"any" | Any characters except the slot's two delimiters, spaces included |
| A list | Word characters and - |
- A delimited slot is never empty.
- Consecutive delimited slots each appear at most once, in declaration order.
Values
valuesrestricts a slot to a closed list of spellings.- Each spelling must be matchable by the slot's kind; a
symbolslot cannot list::. - A bare slot tries longer spellings first, independent of list order.
Description
- Separated from the prefix by exactly one space.
- Not empty.
- Trailing whitespace is ignored.
- Content is not checked.