Les messages du garde-fou étaient des littéraux français : l'anglais n'était pas supporté, quelle que soit la valeur de EL_LANG. Onze clés passent désormais par t(), pour 6 ms de surcoût mesuré par commit. L'en-tête annonçait « sujet » alors que le contrôle lit aussi le corps ; il dit « message ». Les tests ne passaient que parce que le dépôt est en français : un poste en anglais en cassait quarante. La langue devient une précondition — épinglée en mémoire, car set_lang() écrirait un fichier suivi — et les assertions qui citent du texte français se sautent en nommant leur raison. Vérifié en basculant EL_LANG : 48 tests OK en français, 2 sautés en anglais. --- EN --- The guard rail's messages were French literals: English was not supported at all, whatever EL_LANG said. Eleven keys now go through t(), for a measured 6 ms of overhead per commit. The header announced "subject" while the check reads the body too; it says "message". The tests passed only because the repository is in French: a workstation in English broke forty of them. The language becomes a precondition — pinned in memory, since set_lang() would write a tracked file — and the assertions quoting French text skip while naming their reason. Checked by switching EL_LANG: 48 tests OK in French, 2 skipped in English. Assisted-by: Claude Opus 5
59 lines
1.5 KiB
Python
Executable file
59 lines
1.5 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
# © 2026 TechnoLibre (http://www.technolibre.ca)
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
|
|
"""Hook commit-msg : refuse un sujet hors convention.
|
|
|
|
Installation :
|
|
|
|
git config core.hooksPath script/git/hooks
|
|
|
|
Contournement pour un cas légitime : `git commit --no-verify`.
|
|
"""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
|
|
from commit_msg_lib import check # noqa: E402
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[3]))
|
|
|
|
try:
|
|
from script.todo.todo_i18n import t
|
|
except Exception: # pragma: no cover - repli si i18n indisponible
|
|
|
|
def t(key: str) -> str:
|
|
return key
|
|
|
|
|
|
def main() -> int:
|
|
if len(sys.argv) < 2:
|
|
print(t("commit-msg: no message file received"), file=sys.stderr)
|
|
return 1
|
|
path = Path(sys.argv[1])
|
|
try:
|
|
message = path.read_text(encoding="utf-8")
|
|
except OSError as exc:
|
|
print(f"commit-msg : {exc}", file=sys.stderr)
|
|
return 1
|
|
|
|
problems = check(message)
|
|
if not problems:
|
|
return 0
|
|
|
|
print("\n ✗ %s\n" % t("commit message off convention"), file=sys.stderr)
|
|
for problem in problems:
|
|
print(f" - {problem}", file=sys.stderr)
|
|
print(
|
|
t(
|
|
"\n The rule: .claude/rules/04-code-conventions.md"
|
|
"\n The manual: conf/template_claude_commands_commit.md"
|
|
"\n Override for a legitimate case: git commit --no-verify\n"
|
|
),
|
|
file=sys.stderr,
|
|
)
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|