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
3 changes: 2 additions & 1 deletion cchk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ignore_authors = ["dependabot[bot]", "copilot[bot]", "pre-commit-ci[bot]", "code
[branch]
# https://conventional-branch.github.io/
conventional_branch = true
allow_branch_types = ["feature", "bugfix", "hotfix", "release", "chore", "feat", "fix", "copilot"]
# Explicit list needed until AI agent prefixes are in a released version of commit-check
allow_branch_types = ["feature", "bugfix", "hotfix", "release", "chore", "feat", "fix", "ai", "claude", "codex", "copilot", "cursor"]
require_rebase_target = "main"
ignore_authors = ["dependabot[bot]", "copilot[bot]", "pre-commit-ci[bot]", "shenxianpeng"]
9 changes: 8 additions & 1 deletion commit_check/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"build",
"ci",
]
# Follow conventional branch
# Follow conventional branch (https://conventionalbranch.org/)
# Includes AI agent prefixes added in spec v1.1.0
DEFAULT_BRANCH_TYPES = [
"feature",
"bugfix",
Expand All @@ -40,6 +41,12 @@
"chore",
"feat",
"fix",
# AI agent prefixes (conventional branch spec v1.1.0)
"ai",
"claude",
"codex",
"copilot",
"cursor",
]
# Additional allowed branch names (e.g., develop, staging)
DEFAULT_BRANCH_NAMES: list[str] = []
Expand Down
29 changes: 29 additions & 0 deletions tests/rule_builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,35 @@ def test_rule_builder_allow_branch_names_empty_list(self):
assert "(HEAD)" in rule.regex
assert "(PR-.+)" in rule.regex

@pytest.mark.benchmark
def test_ai_agent_branch_types_in_default(self):
"""AI agent prefixes from conventional branch spec v1.1.0 are valid by default."""
import re
from commit_check import DEFAULT_BRANCH_TYPES

assert "ai" in DEFAULT_BRANCH_TYPES
assert "claude" in DEFAULT_BRANCH_TYPES
assert "codex" in DEFAULT_BRANCH_TYPES
assert "copilot" in DEFAULT_BRANCH_TYPES
assert "cursor" in DEFAULT_BRANCH_TYPES

config = {"branch": {"conventional_branch": True}}
builder = RuleBuilder(config)
catalog_entry = RuleCatalogEntry(check="branch", regex="", error="", suggest="")
rule = builder._build_conventional_branch_rule(catalog_entry)
assert rule is not None

ai_agent_branches = [
"ai/refactor-auth-flow",
"claude/stoic-hypatia-v65p1f",
"claude/fix-login-bug",
"codex/optimize-query",
"copilot/add-login-page",
"cursor/fix-header-bug",
]
for branch in ai_agent_branches:
assert re.match(rule.regex, branch), f"Branch '{branch}' should be valid"

@pytest.mark.benchmark
def test_rule_builder_allow_branch_names_with_duplicates(self):
"""Test RuleBuilder with duplicate branch names in allow_branch_names."""
Expand Down
Loading