Skip to content

Commit decded8

Browse files
committed
fix: update rules.py and cchk.toml
1 parent 76cc6e3 commit decded8

2 files changed

Lines changed: 8 additions & 21 deletions

File tree

‎cchk.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ subject_capitalized = false
55
subject_imperative = true
66
subject_max_length = 50
77
subject_min_length = 5
8-
allow_commit_types = ["feat", "fix", "docs", "style", "refactor", "test", "chore"]
8+
allow_commit_types = ["feat", "fix", "docs", "style", "refactor", "test", "chore", "ci"]
99
allow_merge_commits = true
1010
allow_revert_commits = true
1111
allow_empty_commits = false

‎commit_check/rules.py‎

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,14 @@ def build_checks_from_toml(conf: Dict[str, Any]) -> Dict[str, List[Dict[str, Any
6767
author_cfg = conf.get("author", {}) or {}
6868

6969
# --- commit section ---
70-
if commit_cfg.get("conventional_commits", True):
71-
allowed_types = commit_cfg.get("allow_commit_types") or [
72-
"feat", "fix", "docs", "style", "refactor", "test", "chore",
73-
]
74-
allowed_re = "|".join(sorted(set(allowed_types)))
75-
conv_regex = rf"^({allowed_re}){{1}}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)|(Merge).*|(fixup!.*)"
70+
allowed_types_cfg = commit_cfg.get("allow_commit_types")
71+
if isinstance(allowed_types_cfg, list) and allowed_types_cfg:
7672
checks.append({
77-
"check": "message",
78-
"regex": conv_regex,
79-
"error": "The commit message should follow Conventional Commits. See https://www.conventionalcommits.org",
80-
"suggest": "Use <type>(<scope>): <description> with allowed types",
81-
"allowed_types": allowed_types,
73+
"check": "allow_commit_types",
74+
"regex": "",
75+
"error": "Commit type is not in the allowed list",
76+
"suggest": "Use an allowed type or update configuration",
77+
"allowed": allowed_types_cfg,
8278
})
8379

8480
if commit_cfg.get("subject_capitalized", True):
@@ -116,15 +112,6 @@ def build_checks_from_toml(conf: Dict[str, Any]) -> Dict[str, List[Dict[str, Any
116112
"value": min_len,
117113
})
118114

119-
allowed_types_cfg = commit_cfg.get("allow_commit_types")
120-
if isinstance(allowed_types_cfg, list) and allowed_types_cfg:
121-
checks.append({
122-
"check": "allow_commit_types",
123-
"regex": "",
124-
"error": "Commit type is not in the allowed list",
125-
"suggest": "Use an allowed type or update configuration",
126-
"allowed": allowed_types_cfg,
127-
})
128115

129116
if commit_cfg.get("allow_merge_commits", True) is False:
130117
checks.append({

0 commit comments

Comments
 (0)