def check_gitcliff_config(project: Path) -> CheckResult:
"""Check 31: [tool.git-cliff] section in pyproject.toml."""
path = project / "pyproject.toml"
if not path.exists():
return CheckResult(
name="changelog.gitcliff",
category="changelog",
passed=False,
weight=3,
message="pyproject.toml not found",
details=[],
fix="Create pyproject.toml with [tool.git-cliff] section.",
)
try:
with path.open("rb") as f:
data = tomllib.load(f)
except Exception:
return CheckResult(
name="changelog.gitcliff",
category="changelog",
passed=False,
weight=3,
message="pyproject.toml unparsable",
details=[],
fix="Fix TOML syntax and add [tool.git-cliff] section.",
)
if "git-cliff" not in data.get("tool", {}):
return CheckResult(
name="changelog.gitcliff",
category="changelog",
passed=False,
weight=3,
message="No [tool.git-cliff] config found",
details=["git-cliff auto-generates CHANGELOG from conventional commits"],
fix=(
"Add [tool.git-cliff.changelog] and"
" [tool.git-cliff.git] to pyproject.toml."
),
)
return CheckResult(
name="changelog.gitcliff",
category="changelog",
passed=True,
weight=3,
message="git-cliff configured",
details=[],
fix="",
)