Scripts used by git-hooks in Galacticus repos.
The commit-msg hook enforces Conventional Commit format.
The pre-commit hook is a dispatcher that runs every executable file in the pre-commit.d/ directory in lexical order, aborting the commit if any of them fails. To add a new check, drop an executable script into pre-commit.d/ (using a numeric prefix to control ordering).
The following scripts ship in pre-commit.d/:
Runs a number of checks on staged files:
- Fortran static analysis (e.g. empty constructors/destructors, duplicate variables in
constructorAssigndirectives); - bibliography (
.bib) file validation; - spell checking of LaTeX content;
- Python script compilation (
.py); - XML/XSD well-formedness, plus a check for non-ASCII characters;
- YAML linting (
.yml, whenyamllintis available); - compilation of Galacticus embedded XML and LaTeX fragments;
- detection of leftover debugging statements (e.g.
AJB HACK) in Perl, Fortran, and C/C++ sources.
Reviews the staged diff with claude and blocks the commit if it finds serious issues (obvious bugs, leftover debug code, committed secrets, merge-conflict markers, or large blocks of commented-out code). Skipped silently if claude is not installed. Set SKIP_CLAUDE=1 to bypass, or CLAUDE_HOOK_MAX_LINES to change the diff-size cutoff (default 1500 lines).
The prepare-commit-msg hook pre-fills the commit message with a Conventional-Commits-formatted suggestion generated by claude from the staged diff. The original (empty) message is preserved below a marker line so it can be edited or replaced. Skipped silently if claude is not installed, if a message was already supplied (e.g. via -m, -t, merge, squash, or amend), or if the diff exceeds CLAUDE_MSG_MAX_LINES (default 2000). Set SKIP_CLAUDE=1 to bypass.
The pre-push makes you confirm if you really, really want to push directly to the master|main branch - think twice before you do.....
Released under the MIT License.