Skip to content

Commit 565af1a

Browse files
authored
docs: update README.rst for v2 (#288)
* docs: update README.rst for v2 * chore: Update cchk.toml * docs: update configuration.rst
1 parent 41af6df commit 565af1a

3 files changed

Lines changed: 81 additions & 77 deletions

File tree

README.rst

Lines changed: 44 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ Configuration
4242
Use Default Configuration
4343
~~~~~~~~~~~~~~~~~~~~~~~~~
4444

45-
- **Commit Check** uses a `default configuration <https://github.com/commit-check/commit-check/blob/main/commit_check/__init__.py>`_ if you do not provide a ``.commit-check.yml`` file.
45+
- **Commit Check** uses a `default configuration <https://github.com/commit-check/commit-check/blob/main/docs/configuration.rst>`_ if you do not provide a ``cchk.toml`` or ``commit-check.toml`` file.
4646

4747
- The default configuration enforces commit message rules based on the `Conventional Commits <https://www.conventionalcommits.org/en/v1.0.0/#summary>`_ specification and branch naming rules based on the `Conventional Branch <https://conventional-branch.github.io/#summary>`_ convention.
4848

4949
Use Custom Configuration
5050
~~~~~~~~~~~~~~~~~~~~~~~~
5151

52-
To customize the behavior, create a config file ``.commit-check.yml`` under your repository's root directory, e.g., `.commit-check.yml <https://github.com/commit-check/commit-check/blob/main/.commit-check.yml>`_
52+
To customize the behavior, create a config file ``cchk.toml`` or ``commit-check.toml`` under your repository's root directory, e.g., `cchk.toml <https://github.com/commit-check/commit-check/blob/main/cchk.toml>`_
5353

5454
Usage
5555
-----
@@ -75,9 +75,6 @@ Running as pre-commit hook
7575
- id: check-branch
7676
- id: check-author-name
7777
- id: check-author-email
78-
- id: check-commit-signoff
79-
- id: check-merge-base # requires download all git history
80-
- id: check-imperative
8178
8279
Running as CLI
8380
~~~~~~~~~~~~~~
@@ -112,7 +109,7 @@ To configure the hook, create a script file in the ``.git/hooks/`` directory.
112109
.. code-block:: bash
113110
114111
#!/bin/sh
115-
commit-check --message --branch --author-name --author-email --commit-signoff --merge-base --imperative
112+
commit-check --message --branch --author-name --author-email
116113
117114
Save the script file as ``pre-push`` and make it executable:
118115

@@ -131,26 +128,21 @@ Check Commit Message Failed
131128
132129
Commit rejected by Commit-Check.
133130
134-
(c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c)
135-
/ ._. \ / ._. \ / ._. \ / ._. \ / ._. \
136-
__\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__
131+
(c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c)
132+
/ ._. \ / ._. \ / ._. \ / ._. \ / ._. \
133+
__\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__
137134
(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)
138-
|| E || || R || || R || || O || || R ||
139-
_.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._
135+
|| E || || R || || R || || O || || R ||
136+
_.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._
140137
(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)
141-
`-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´
138+
`-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´
142139
143-
Type message check failed => my test commit message
144-
It doesn't match regex: ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)
145-
146-
The commit message should be structured as follows:
147-
148-
<type>[optional scope]: <description>
149-
[optional body]
150-
[optional footer(s)]
140+
Commit rejected.
151141
152-
More details please refer to https://www.conventionalcommits.org
153-
Suggest: please check your commit message whether matches above regex
142+
Type message check failed ==> test commit message check
143+
It doesn't match regex: ^(chore|ci|docs|feat|fix|refactor|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)|(Merge).*|(fixup!.*)
144+
The commit message should follow Conventional Commits. See https://www.conventionalcommits.org
145+
Suggest: Use <type>(<scope>): <description> with allowed types
154146
155147
156148
Check Branch Naming Failed
@@ -159,21 +151,21 @@ Check Branch Naming Failed
159151
160152
Commit rejected by Commit-Check.
161153
162-
(c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c)
163-
/ ._. \ / ._. \ / ._. \ / ._. \ / ._. \
164-
__\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__
154+
(c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c)
155+
/ ._. \ / ._. \ / ._. \ / ._. \ / ._. \
156+
__\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__
165157
(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)
166-
|| E || || R || || R || || O || || R ||
167-
_.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._
158+
|| E || || R || || R || || O || || R ||
159+
_.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._
168160
(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)
169-
`-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´
161+
`-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´
170162
171163
Commit rejected.
172164
173-
Type branch check failed => patch-1
174-
It doesn't match regex: ^(bugfix|feature|release|hotfix|task|chore)\/.+|(master)|(main)|(HEAD)|(PR-.+)
175-
Branches must begin with these types: bugfix/ feature/ release/ hotfix/ task/ chore/
176-
Suggest: run command `git checkout -b type/branch_name`
165+
Type branch check failed ==> test-branch
166+
It doesn't match regex: ^(feature|bugfix|hotfix|release|chore|feat|fix)\/.+|(master)|(main)|(HEAD)|(PR-.+)
167+
The branch should follow Conventional Branch. See https://conventional-branches.github.io/
168+
Suggest: git checkout -b <type>/<branch_name>
177169
178170
179171
Check Commit Signature Failed
@@ -182,21 +174,21 @@ Check Commit Signature Failed
182174
183175
Commit rejected by Commit-Check.
184176
185-
(c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c)
186-
/ ._. \ / ._. \ / ._. \ / ._. \ / ._. \
187-
__\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__
177+
(c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c)
178+
/ ._. \ / ._. \ / ._. \ / ._. \ / ._. \
179+
__\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__
188180
(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)
189-
|| E || || R || || R || || O || || R ||
190-
_.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._
181+
|| E || || R || || R || || O || || R ||
182+
_.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._
191183
(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)
192-
`-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´
184+
`-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´
193185
194186
Commit rejected.
195187
196-
Type signoff check failed => c92ce259ff041c91859c7fb61afdbb391e769d0f
188+
Type require_signed_off_by check failed ==> fix: add missing file
197189
It doesn't match regex: Signed-off-by:.*[A-Za-z0-9]\s+<.+@.+>
198190
Signed-off-by not found in latest commit
199-
Suggest: run command `git commit -m "conventional commit message" --signoff`
191+
Suggest: git commit --amend --signoff or use --signoff on commit
200192
201193
202194
Check Imperative Mood Failed
@@ -205,22 +197,24 @@ Check Imperative Mood Failed
205197
206198
Commit rejected by Commit-Check.
207199
208-
(c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c)
209-
/ ._. \ / ._. \ / ._. \ / ._. \ / ._. \
210-
__\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__
200+
(c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c)
201+
/ ._. \ / ._. \ / ._. \ / ._. \ / ._. \
202+
__\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__
211203
(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)
212-
|| E || || R || || R || || O || || R ||
213-
_.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._
204+
|| E || || R || || R || || O || || R ||
205+
_.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._
214206
(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)
215-
`-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´
207+
`-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´
216208
217209
Commit rejected.
218210
219-
Type imperative check failed => Added file
220-
It doesn't match regex: imperative mood pattern
221-
Commit message should use imperative mood (e.g., "Add feature" not "Added feature")
222-
Suggest: Use imperative mood in commit message like "Add", "Fix", "Update", "Remove"
211+
Type imperative check failed ==> fix: added missing file
212+
It doesn't match regex:
213+
Commit message should use imperative mood (e.g., 'Add feature' not 'Added feature')
214+
Suggest: Use imperative mood in the subject line
215+
223216
217+
And many more... see `commit-check.toml <cchk.toml>`_ for all available checks.
224218

225219
Badging your repository
226220
-----------------------

cchk.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
conventional_commits = true
44
subject_capitalized = false
55
subject_imperative = true
6-
subject_max_length = 50
6+
subject_max_length = 80
77
subject_min_length = 5
88
allow_commit_types = ["feat", "fix", "docs", "style", "refactor", "test", "chore", "ci"]
99
allow_merge_commits = true

docs/configuration.rst

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ Configuration
33

44
``commit-check`` configuration file support TOML format.
55

6-
See ``cchk.toml`` for the default configuration values.
6+
See ``cchk.toml`` for an example configuration.
77

8+
**Default Behavior**: When no configuration file exists, commit-check uses sensible defaults with minimal restrictions.
9+
10+
Only conventional commits format, subject capitalization, and imperative mood are enforced by default.
11+
12+
No length limits, author restrictions, or rebase requirements are applied.
813

914
commit-check can be configured via a ``cchk.toml`` or ``commit-check.toml`` file.
1015

@@ -17,26 +22,26 @@ The file should be placed in the root of your repository.
1722
conventional_commits = true
1823
subject_capitalized = true
1924
subject_imperative = true
20-
subject_max_length = 50
21-
subject_min_length = 5
25+
# subject_max_length = 50 # Optional - no limit by default
26+
# subject_min_length = 5 # Optional - no limit by default
2227
allow_commit_types = ["feat", "fix", "docs", "style", "refactor", "test", "chore"]
2328
allow_merge_commits = true
2429
allow_revert_commits = true
2530
allow_empty_commits = false
2631
allow_fixup_commits = true
2732
allow_wip_commits = false
2833
require_body = false
29-
allow_authors = []
30-
ignore_authors = ["dependabot[bot]", "dependabot-preview[bot]"]
31-
require_signed_off_by = true
32-
required_signoff_name = "Your Name"
33-
required_signoff_email = "your.email@example.com"
34+
# allow_authors = [] # Optional - all authors allowed by default
35+
# ignore_authors = [] # Optional - no authors ignored by default
36+
require_signed_off_by = false
37+
# required_signoff_name = "Your Name" # Optional
38+
# required_signoff_email = "your.email@example.com" # Optional
3439
3540
[branch]
3641
# https://conventional-branch.github.io/
3742
conventional_branch = true
3843
allow_branch_types = ["feature", "bugfix", "hotfix", "release", "chore", "feat", "fix"]
39-
require_rebase_target = "main"
44+
# require_rebase_target = "main" # Optional - no rebase requirement by default
4045
4146
4247
@@ -69,12 +74,12 @@ options table description
6974
* - commit
7075
- subject_max_length
7176
- int
72-
- 50
77+
- None (no limit)
7378
- Maximum length of the subject line.
7479
* - commit
7580
- subject_min_length
7681
- int
77-
- 5
82+
- None (no limit)
7883
- Minimum length of the subject line.
7984
* - commit
8085
- allow_commit_types
@@ -111,6 +116,21 @@ options table description
111116
- bool
112117
- false
113118
- Require a body in the commit message.
119+
* - commit
120+
- allow_authors
121+
- list[str]
122+
- [] (all allowed)
123+
- List of allowed authors. If empty, all authors are allowed except those in ignore_authors.
124+
* - commit
125+
- ignore_authors
126+
- list[str]
127+
- [] (none ignored)
128+
- List of authors to ignore (i.e., always allow).
129+
* - commit
130+
- require_signed_off_by
131+
- bool
132+
- false
133+
- Require "Signed-off-by" line in the commit message footer.
114134
* - branch
115135
- conventional_branch
116136
- bool
@@ -121,18 +141,8 @@ options table description
121141
- list[str]
122142
- ["feature", "bugfix", "hotfix", "release", "chore", "feat", "fix"]
123143
- Allowed branch types when conventional_branch is true.
124-
* - author
125-
- allow_authors
126-
- list[str]
127-
- []
128-
- List of allowed authors. If empty, all authors are allowed except those in ignore_authors.
129-
* - author
130-
- ignore_authors
131-
- list[str]
132-
- ["dependabot[bot]", "dependabot-preview[bot]"]
133-
- List of authors to ignore (i.e., always allow).
134-
* - author
135-
- require_signed_off_by
136-
- bool
137-
- true
138-
- Require "Signed-off-by" line in the commit message footer.
144+
* - branch
145+
- require_rebase_target
146+
- str
147+
- None (no requirement)
148+
- Target branch for rebase requirement. If not set, no rebase validation is performed.

0 commit comments

Comments
 (0)