Skip to content

Support new configuration file commit-check.toml #273

@shenxianpeng

Description

@shenxianpeng

What's the problem this feature will solve?

I want a new configuration for commit-check that is easier to configure and read.

Current config file is .commit-check.yml

checks:
  - check: message
    regex: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)|(Merge).*|(fixup!.*)'
    error: "The commit message should be structured as follows:\n\n
    <type>[optional scope]: <description>\n
    [optional body]\n
    [optional footer(s)]\n\n
    More details please refer to https://www.conventionalcommits.org"
    suggest: please check your commit message whether matches above regex

  - check: branch
    regex: ^(bugfix|feature|release|hotfix|task|chore)\/.+|(master)|(main)|(HEAD)|(PR-.+)
    error: "Branches must begin with these types: bugfix/ feature/ release/ hotfix/ task/ chore/"
    suggest: run command `git checkout -b type/branch_name`

  - check: author_name
    regex: ^[A-Za-zÀ-ÖØ-öø-ÿ\u0100-\u017F\u0180-\u024F ,.\'-]+$|.*(\[bot])
    error: The committer name seems invalid
    suggest: run command `git config user.name "Your Name"`

  - check: author_email
    regex: ^.+@.+$
    error: The committer email seems invalid
    suggest: run command `git config user.email yourname@example.com`

  - check: commit_signoff
    regex: Signed-off-by:.*[A-Za-z0-9]\s+<.+@.+>
    error: Signed-off-by not found in latest commit
    suggest: run command `git commit -m "conventional commit message" --signoff`

  - check: merge_base
    regex: main # it can be master, develop, devel etc based on your project.
    error: Current branch is not rebased onto target branch
    suggest: Please ensure your branch is rebased with the target branch

  - check: imperative
    regex: '' # Not used for imperative mood check
    error: '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"'

The new config will be commit-check.toml or cchk.toml

subject_length, default 50 (if it to 0 means no limit)
line_length, default 72 (if it is 0 means no limit)
subject_capitalized, default true. Whether the subject is required to be capitalized
subject_not_punctuated. default true. Prevent the subject from ending in punctuation
imperative_subject
no_wip
no_fixup

for example

commit_style = "conventional"
subject_capitalized = false
subject_length = 0
line_length = 0

# Allowed conventional commit types
commit_allowed_types = [
  "fix",
  "feat",
  "build",
  "chore",
  "ci",
  "docs",
  "style",
  "refactor",
  "remove",
  "deprecate",
  "security",
  "add",
  "perf",
  "test",
]

branch_style = "conventional"

# Allowed conventional branch types
branch_allowed_prefixes = [
  "bugfix",
  "feature",
  "release",
  "hotfix",
  "chore",
]

Describe the solution you'd like

Ref:

Metadata

Metadata

Assignees

Labels

breakingThis is a breaking changeenhancementNew feature or requestmajorA major version bump

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions