Files
cimtechniques-service-suite/scripts/commit_msg_hook.py
Andy 63169a7644 feat: add versioning and changelog system
Conventional-Commit-driven version bumps (scripts/bump.py), a commit-msg validation hook, and a /release-notes workflow that produces a human-reviewed CHANGELOG.md. Adds an in-app version badge + 'What's new' dialog on the launcher. The version is single-sourced from pyproject.toml (cim_suite.__version__), and the deterministic bump backbone lives in scripts/release/ with tests in tests/release/. Marks the 1.0.0 baseline.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-06 11:31:22 -04:00

38 lines
1.1 KiB
Python

#!/usr/bin/env python
"""commit-msg hook body: reject messages that aren't ``<type>: <description>``.
Invoked by ``.githooks/commit-msg`` with the path to the commit message file.
Validation logic lives in :mod:`release.commits` so it is unit-tested.
"""
from __future__ import annotations
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from release.commits import KNOWN_TYPES, validate_commit_message # noqa: E402
def main(argv: list[str]) -> int:
if len(argv) < 2:
return 0
message = Path(argv[1]).read_text("utf-8")
error = validate_commit_message(message)
if error is None:
return 0
indented = "\n ".join(error.splitlines())
sys.stderr.write(
"\n x Commit rejected: invalid commit message.\n\n"
f" {indented}\n\n"
f" Format : <type>(<optional scope>): <description>\n"
f" Types : {', '.join(KNOWN_TYPES)}\n"
" Example: feat(da12): add live sensor sparkline\n\n"
)
return 1
if __name__ == "__main__":
raise SystemExit(main(sys.argv))