From 7f8006302e1c0c975448506f951a1c610d66859b Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Fri, 3 Oct 2025 21:04:44 +0300 Subject: [PATCH 1/3] docs: update README.rst for v2 --- README.rst | 94 +++++++++++++++++++++++++----------------------------- cchk.toml | 4 +-- 2 files changed, 46 insertions(+), 52 deletions(-) diff --git a/README.rst b/README.rst index a01f75ab..088d5dc6 100644 --- a/README.rst +++ b/README.rst @@ -42,14 +42,14 @@ Configuration Use Default Configuration ~~~~~~~~~~~~~~~~~~~~~~~~~ -- **Commit Check** uses a `default configuration `_ if you do not provide a ``.commit-check.yml`` file. +- **Commit Check** uses a `default configuration `_ if you do not provide a ``cchk.toml`` or ``commit-check.toml`` file. - The default configuration enforces commit message rules based on the `Conventional Commits `_ specification and branch naming rules based on the `Conventional Branch `_ convention. Use Custom Configuration ~~~~~~~~~~~~~~~~~~~~~~~~ -To customize the behavior, create a config file ``.commit-check.yml`` under your repository's root directory, e.g., `.commit-check.yml `_ +To customize the behavior, create a config file ``cchk.toml`` or ``commit-check.toml`` under your repository's root directory, e.g., `cchk.toml `_ Usage ----- @@ -75,9 +75,6 @@ Running as pre-commit hook - id: check-branch - id: check-author-name - id: check-author-email - - id: check-commit-signoff - - id: check-merge-base # requires download all git history - - id: check-imperative Running as CLI ~~~~~~~~~~~~~~ @@ -112,7 +109,7 @@ To configure the hook, create a script file in the ``.git/hooks/`` directory. .. code-block:: bash #!/bin/sh - commit-check --message --branch --author-name --author-email --commit-signoff --merge-base --imperative + commit-check --message --branch --author-name --author-email Save the script file as ``pre-push`` and make it executable: @@ -131,26 +128,21 @@ Check Commit Message Failed Commit rejected by Commit-Check. - (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) - / ._. \ / ._. \ / ._. \ / ._. \ / ._. \ - __\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__ + (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) + / ._. \ / ._. \ / ._. \ / ._. \ / ._. \ + __\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__ (_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._) - || E || || R || || R || || O || || R || - _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ + || E || || R || || R || || O || || R || + _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ (.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.) - `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ + `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ - Type message check failed => my test commit message - It doesn't match regex: ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*) - - The commit message should be structured as follows: - - [optional scope]: - [optional body] - [optional footer(s)] + Commit rejected. - More details please refer to https://www.conventionalcommits.org - Suggest: please check your commit message whether matches above regex + Type message check failed ==> test commit message check + It doesn't match regex: ^(chore|ci|docs|feat|fix|refactor|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)|(Merge).*|(fixup!.*) + The commit message should follow Conventional Commits. See https://www.conventionalcommits.org + Suggest: Use (): with allowed types Check Branch Naming Failed @@ -159,21 +151,21 @@ Check Branch Naming Failed Commit rejected by Commit-Check. - (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) - / ._. \ / ._. \ / ._. \ / ._. \ / ._. \ - __\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__ + (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) + / ._. \ / ._. \ / ._. \ / ._. \ / ._. \ + __\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__ (_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._) - || E || || R || || R || || O || || R || - _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ + || E || || R || || R || || O || || R || + _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ (.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.) - `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ + `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ Commit rejected. - Type branch check failed => patch-1 - It doesn't match regex: ^(bugfix|feature|release|hotfix|task|chore)\/.+|(master)|(main)|(HEAD)|(PR-.+) - Branches must begin with these types: bugfix/ feature/ release/ hotfix/ task/ chore/ - Suggest: run command `git checkout -b type/branch_name` + Type branch check failed ==> test-branch + It doesn't match regex: ^(feature|bugfix|hotfix|release|chore|feat|fix)\/.+|(master)|(main)|(HEAD)|(PR-.+) + The branch should follow Conventional Branch. See https://conventional-branches.github.io/ + Suggest: git checkout -b / Check Commit Signature Failed @@ -182,21 +174,21 @@ Check Commit Signature Failed Commit rejected by Commit-Check. - (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) - / ._. \ / ._. \ / ._. \ / ._. \ / ._. \ - __\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__ + (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) + / ._. \ / ._. \ / ._. \ / ._. \ / ._. \ + __\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__ (_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._) - || E || || R || || R || || O || || R || - _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ + || E || || R || || R || || O || || R || + _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ (.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.) - `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ + `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ Commit rejected. - Type signoff check failed => c92ce259ff041c91859c7fb61afdbb391e769d0f + Type require_signed_off_by check failed ==> fix: add missing file It doesn't match regex: Signed-off-by:.*[A-Za-z0-9]\s+<.+@.+> Signed-off-by not found in latest commit - Suggest: run command `git commit -m "conventional commit message" --signoff` + Suggest: git commit --amend --signoff or use --signoff on commit Check Imperative Mood Failed @@ -205,22 +197,24 @@ Check Imperative Mood Failed Commit rejected by Commit-Check. - (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) - / ._. \ / ._. \ / ._. \ / ._. \ / ._. \ - __\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__ + (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) + / ._. \ / ._. \ / ._. \ / ._. \ / ._. \ + __\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__ (_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._) - || E || || R || || R || || O || || R || - _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ + || E || || R || || R || || O || || R || + _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ (.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.) - `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ + `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ Commit rejected. - Type imperative check failed => Added file - It doesn't match regex: imperative mood pattern - Commit message should use imperative mood (e.g., "Add feature" not "Added feature") - Suggest: Use imperative mood in commit message like "Add", "Fix", "Update", "Remove" + Type imperative check failed ==> fix: added missing file + It doesn't match regex: + Commit message should use imperative mood (e.g., 'Add feature' not 'Added feature') + Suggest: Use imperative mood in the subject line + +And many more... see `commit-check.toml `_ for all available checks. Badging your repository ----------------------- diff --git a/cchk.toml b/cchk.toml index 311599b7..0bf6e4a7 100644 --- a/cchk.toml +++ b/cchk.toml @@ -3,7 +3,7 @@ conventional_commits = true subject_capitalized = false subject_imperative = true -subject_max_length = 50 +subject_max_length = 80 subject_min_length = 5 allow_commit_types = ["feat", "fix", "docs", "style", "refactor", "test", "chore", "ci"] allow_merge_commits = true @@ -12,7 +12,7 @@ allow_empty_commits = false allow_fixup_commits = true allow_wip_commits = false require_body = false -require_signed_off_by = false +require_signed_off_by = true allow_authors = [] ignore_authors = ["dependabot[bot]", "copilot[bot]"] From a4e086da4256ba623dc1e79f03547df35a372b68 Mon Sep 17 00:00:00 2001 From: Xianpeng Shen Date: Fri, 3 Oct 2025 21:45:21 +0300 Subject: [PATCH 2/3] chore: Update cchk.toml --- cchk.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cchk.toml b/cchk.toml index 0bf6e4a7..08ffcbf8 100644 --- a/cchk.toml +++ b/cchk.toml @@ -12,7 +12,7 @@ allow_empty_commits = false allow_fixup_commits = true allow_wip_commits = false require_body = false -require_signed_off_by = true +require_signed_off_by = false allow_authors = [] ignore_authors = ["dependabot[bot]", "copilot[bot]"] From dcf8ffb382bff711332c2840c8085b32828a8a14 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Fri, 3 Oct 2025 21:52:51 +0300 Subject: [PATCH 3/3] docs: update configuration.rst --- docs/configuration.rst | 62 ++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 9f4f5a98..2e64e202 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -3,8 +3,13 @@ Configuration ``commit-check`` configuration file support TOML format. -See ``cchk.toml`` for the default configuration values. +See ``cchk.toml`` for an example configuration. +**Default Behavior**: When no configuration file exists, commit-check uses sensible defaults with minimal restrictions. + +Only conventional commits format, subject capitalization, and imperative mood are enforced by default. + +No length limits, author restrictions, or rebase requirements are applied. commit-check can be configured via a ``cchk.toml`` or ``commit-check.toml`` file. @@ -17,8 +22,8 @@ The file should be placed in the root of your repository. conventional_commits = true subject_capitalized = true subject_imperative = true - subject_max_length = 50 - subject_min_length = 5 + # subject_max_length = 50 # Optional - no limit by default + # subject_min_length = 5 # Optional - no limit by default allow_commit_types = ["feat", "fix", "docs", "style", "refactor", "test", "chore"] allow_merge_commits = true allow_revert_commits = true @@ -26,17 +31,17 @@ The file should be placed in the root of your repository. allow_fixup_commits = true allow_wip_commits = false require_body = false - allow_authors = [] - ignore_authors = ["dependabot[bot]", "dependabot-preview[bot]"] - require_signed_off_by = true - required_signoff_name = "Your Name" - required_signoff_email = "your.email@example.com" + # allow_authors = [] # Optional - all authors allowed by default + # ignore_authors = [] # Optional - no authors ignored by default + require_signed_off_by = false + # required_signoff_name = "Your Name" # Optional + # required_signoff_email = "your.email@example.com" # Optional [branch] # https://conventional-branch.github.io/ conventional_branch = true allow_branch_types = ["feature", "bugfix", "hotfix", "release", "chore", "feat", "fix"] - require_rebase_target = "main" + # require_rebase_target = "main" # Optional - no rebase requirement by default @@ -69,12 +74,12 @@ options table description * - commit - subject_max_length - int - - 50 + - None (no limit) - Maximum length of the subject line. * - commit - subject_min_length - int - - 5 + - None (no limit) - Minimum length of the subject line. * - commit - allow_commit_types @@ -111,6 +116,21 @@ options table description - bool - false - Require a body in the commit message. + * - commit + - allow_authors + - list[str] + - [] (all allowed) + - List of allowed authors. If empty, all authors are allowed except those in ignore_authors. + * - commit + - ignore_authors + - list[str] + - [] (none ignored) + - List of authors to ignore (i.e., always allow). + * - commit + - require_signed_off_by + - bool + - false + - Require "Signed-off-by" line in the commit message footer. * - branch - conventional_branch - bool @@ -121,18 +141,8 @@ options table description - list[str] - ["feature", "bugfix", "hotfix", "release", "chore", "feat", "fix"] - Allowed branch types when conventional_branch is true. - * - author - - allow_authors - - list[str] - - [] - - List of allowed authors. If empty, all authors are allowed except those in ignore_authors. - * - author - - ignore_authors - - list[str] - - ["dependabot[bot]", "dependabot-preview[bot]"] - - List of authors to ignore (i.e., always allow). - * - author - - require_signed_off_by - - bool - - true - - Require "Signed-off-by" line in the commit message footer. + * - branch + - require_rebase_target + - str + - None (no requirement) + - Target branch for rebase requirement. If not set, no rebase validation is performed.