Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions commit_check/imperatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@
"obtain",
"open",
"output",
"organize",
"orchestrate",
"override",
"overwrite",
"package",
Expand Down
64 changes: 39 additions & 25 deletions commit_check/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def _get_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
prog="commit-check",
description="Check commit message, branch name, author name, email, and more.",
formatter_class=argparse.RawDescriptionHelpFormatter,
)

parser.add_argument(
Expand All @@ -46,152 +47,161 @@ def _get_parser() -> argparse.ArgumentParser:
help="path to config file (cchk.toml or commit-check.toml). If not specified, searches for config in: cchk.toml, commit-check.toml, .github/cchk.toml, .github/commit-check.toml",
)

parser.add_argument(
# Main check type arguments
check_group = parser.add_argument_group(
"check types", "Specify which validation checks to run"
)

check_group.add_argument(
"-m",
"--message",
nargs="?",
const="",
help="validate commit message. Optionally specify file path, otherwise reads from stdin if available",
)

parser.add_argument(
check_group.add_argument(
"-b",
"--branch",
help="check current git branch name",
action="store_true",
required=False,
)

parser.add_argument(
check_group.add_argument(
"-n",
"--author-name",
help="check git author name",
action="store_true",
required=False,
)

parser.add_argument(
check_group.add_argument(
"-e",
"--author-email",
help="check git author email",
action="store_true",
required=False,
)

parser.add_argument(
check_group.add_argument(
"-d",
"--dry-run",
help="perform a dry run without failing (always returns 0)",
action="store_true",
required=False,
)

# Commit configuration options
parser.add_argument(
# Commit message configuration options
commit_group = parser.add_argument_group(
"commit message options", "Configuration options for --message validation"
)

commit_group.add_argument(
"--conventional-commits",
type=parse_bool,
default=None,
metavar="BOOL",
help="enforce conventional commits format (true/false)",
)

parser.add_argument(
commit_group.add_argument(
"--subject-capitalized",
type=parse_bool,
default=None,
metavar="BOOL",
help="require subject to start with capital letter (true/false)",
)

parser.add_argument(
commit_group.add_argument(
"--subject-imperative",
type=parse_bool,
default=None,
metavar="BOOL",
help="require subject to use imperative mood (true/false)",
)

parser.add_argument(
commit_group.add_argument(
"--subject-max-length",
type=parse_int,
default=None,
metavar="INT",
help="maximum length of commit subject",
)

parser.add_argument(
commit_group.add_argument(
"--subject-min-length",
type=parse_int,
default=None,
metavar="INT",
help="minimum length of commit subject",
)

parser.add_argument(
commit_group.add_argument(
"--allow-commit-types",
type=parse_list,
default=None,
metavar="LIST",
help="comma-separated list of allowed commit types (e.g., feat,fix,docs)",
)

parser.add_argument(
commit_group.add_argument(
"--allow-merge-commits",
type=parse_bool,
default=None,
metavar="BOOL",
help="allow merge commits (true/false)",
)

parser.add_argument(
commit_group.add_argument(
"--allow-revert-commits",
type=parse_bool,
default=None,
metavar="BOOL",
help="allow revert commits (true/false)",
)

parser.add_argument(
commit_group.add_argument(
"--allow-empty-commits",
type=parse_bool,
default=None,
metavar="BOOL",
help="allow empty commit messages (true/false)",
)

parser.add_argument(
commit_group.add_argument(
"--allow-fixup-commits",
type=parse_bool,
default=None,
metavar="BOOL",
help="allow fixup commits (true/false)",
)

parser.add_argument(
commit_group.add_argument(
"--allow-wip-commits",
type=parse_bool,
default=None,
metavar="BOOL",
help="allow WIP commits (true/false)",
)

parser.add_argument(
commit_group.add_argument(
"--require-body",
type=parse_bool,
default=None,
metavar="BOOL",
help="require commit body (true/false)",
)

parser.add_argument(
commit_group.add_argument(
"--require-signed-off-by",
type=parse_bool,
default=None,
metavar="BOOL",
help="require 'Signed-off-by' trailer (true/false)",
)

parser.add_argument(
commit_group.add_argument(
"--ignore-authors",
type=parse_list,
default=None,
Expand All @@ -200,39 +210,43 @@ def _get_parser() -> argparse.ArgumentParser:
)

# Branch configuration options
parser.add_argument(
branch_group = parser.add_argument_group(
"branch options", "Configuration options for --branch validation"
)

branch_group.add_argument(
"--conventional-branch",
type=parse_bool,
default=None,
metavar="BOOL",
help="enforce conventional branch naming (true/false)",
)

parser.add_argument(
branch_group.add_argument(
"--allow-branch-types",
type=parse_list,
default=None,
metavar="LIST",
help="comma-separated list of allowed branch types (e.g., feature,bugfix,hotfix)",
)

parser.add_argument(
branch_group.add_argument(
"--allow-branch-names",
type=parse_list,
default=None,
metavar="LIST",
help="comma-separated list of additional allowed branch names",
)

parser.add_argument(
branch_group.add_argument(
"--require-rebase-target",
type=str,
default=None,
metavar="BRANCH",
help="target branch for rebase validation",
)

parser.add_argument(
branch_group.add_argument(
"--branch-ignore-authors",
type=parse_list,
default=None,
Expand Down
Loading