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: 0 additions & 2 deletions cchk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@ ignore_authors = ["dependabot[bot]", "copilot[bot]", "pre-commit-ci[bot]", "code
[branch]
# https://conventionalbranch.org
conventional_branch = true
# 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"]
5 changes: 4 additions & 1 deletion commit_check/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"ci",
]
# Follow conventional branch (https://conventionalbranch.org/)
# Includes AI agent prefixes added in spec v1.1.0
# Includes AI agent prefixes (spec v1.1.0) and bot prefixes
DEFAULT_BRANCH_TYPES = [
"feature",
"bugfix",
Expand All @@ -47,6 +47,9 @@
"codex",
"copilot",
"cursor",
# Automation/bot prefixes
"dependabot",
"renovate",
]
# Additional allowed branch names (e.g., develop, staging)
DEFAULT_BRANCH_NAMES: list[str] = []
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ Options Table Description
- allow_branch_types
- list[str]
- ["feature", "bugfix", "hotfix", "release", "chore", "feat", "fix"]
- Allowed branch types when conventional_branch is true.
- Allowed branch types when conventional_branch is true. AI agent prefixes (``ai/``, ``claude/``, ``codex/``, ``copilot/``, ``cursor/``) and bot prefixes (``dependabot/``) are also included by default.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Keep the documented default value in sync with this description.

This row now says AI-agent and dependabot/ prefixes are included by default, but the Default column on Line 409 still lists only the legacy branch types. Please update that value too so the table does not contradict itself.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/configuration.rst` at line 410, Update the configuration table entry for
the conventional_branch setting so the Default column matches the expanded
description; the current default value still reflects only the legacy branch
types, so revise that default in the table to include the AI-agent prefixes and
dependabot/ alongside the existing branch types. Use the conventional_branch row
in docs/configuration.rst to locate the mismatch and keep the default text
consistent with the description.

* - branch
- allow_branch_names
- list[str]
Expand Down
22 changes: 22 additions & 0 deletions docs/what-is-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@ What's New

This document highlights the major changes and improvements in each version of commit-check.

Version 2.9.1 — Bot Branch Types as Default
---------------------------------------------

``dependabot/`` and ``renovate/`` branches now pass by default
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``dependabot`` and ``renovate`` are now included in ``DEFAULT_BRANCH_TYPES``,
so branches like ``dependabot/go_modules/go-deps-c57c3fe1e0`` and
``renovate/lodash-5.x`` are automatically accepted without manual
``allow_branch_types`` configuration.

Version 2.9.0 — AI Agent Branch Prefixes
----------------------------------------

Conventional Branch v1.1.0 AI agent prefixes supported by default
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``ai/``, ``claude/``, ``codex/``, ``copilot/``, and ``cursor/`` have been
added to ``DEFAULT_BRANCH_TYPES`` as defined in `Conventional Branch
v1.1.0 <https://conventional-branch.github.io/>`_. Branches created by AI
coding agents are now valid out of the box without extra configuration.

Version 2.7.0 — Force Push Blocking
-----------------------------------

Expand Down
39 changes: 39 additions & 0 deletions tests/engine_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,45 @@ def test_branch_validator_staging_branch_allowed(
result = validator.validate(context)
assert result == ValidationResult.PASS

@patch("commit_check.engine.has_commits")
@patch("commit_check.engine.get_branch_name")
@pytest.mark.benchmark
def test_branch_validator_dependabot_branch_allowed(
self, mock_get_branch_name, mock_has_commits
):
"""Test BranchValidator with dependabot branch (default type)."""
mock_has_commits.return_value = True
mock_get_branch_name.return_value = "dependabot/go_modules/go-deps-c57c3fe1e0"
# Regex pattern that includes dependabot as a type prefix
rule = ValidationRule(
check="branch",
regex=r"^(feature|bugfix|hotfix|dependabot)\/.+",
)
validator = BranchValidator(rule)
config = {"branch": {"ignore_authors": []}}
context = ValidationContext(config=config)
result = validator.validate(context)
assert result == ValidationResult.PASS

@patch("commit_check.engine.has_commits")
@patch("commit_check.engine.get_branch_name")
@pytest.mark.benchmark
def test_branch_validator_renovate_branch_allowed(
self, mock_get_branch_name, mock_has_commits
):
"""Test BranchValidator with renovate branch (default type)."""
mock_has_commits.return_value = True
mock_get_branch_name.return_value = "renovate/lodash-5.x"
rule = ValidationRule(
check="branch",
regex=r"^(feature|bugfix|hotfix|dependabot|renovate)\/.+",
)
validator = BranchValidator(rule)
config = {"branch": {"ignore_authors": []}}
context = ValidationContext(config=config)
result = validator.validate(context)
assert result == ValidationResult.PASS

@patch("commit_check.engine.has_commits")
@patch("commit_check.engine.get_branch_name")
@pytest.mark.benchmark
Expand Down
17 changes: 13 additions & 4 deletions tests/rule_builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ def test_rule_builder_allow_branch_names_empty_list(self):
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."""
def test_ai_agent_and_bot_branch_types_in_default(self):
"""AI agent and bot prefixes are valid by default."""
import re
from commit_check import DEFAULT_BRANCH_TYPES

Expand All @@ -226,22 +226,31 @@ def test_ai_agent_branch_types_in_default(self):
assert "codex" in DEFAULT_BRANCH_TYPES
assert "copilot" in DEFAULT_BRANCH_TYPES
assert "cursor" in DEFAULT_BRANCH_TYPES
assert "dependabot" in DEFAULT_BRANCH_TYPES
assert "renovate" 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 = [
valid_branches = [
# 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",
# Bot/automation branches
"dependabot/go_modules/go-deps-c57c3fe1e0",
"dependabot/npm_and_yarn/lodash-4.17.21",
"dependabot/pip/certifi-2022.12.7",
"renovate/lodash-5.x",
"renovate/major-lodash-5.x",
]
for branch in ai_agent_branches:
for branch in valid_branches:
assert re.match(rule.regex, branch), f"Branch '{branch}' should be valid"

@pytest.mark.benchmark
Expand Down
Loading