Skip to content

Latest commit

 

History

69 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gitHooks

Scripts used by git-hooks in Galacticus repos.

commit-msg

The commit-msg hook enforces Conventional Commit format.

pre-commit

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/:

00-galacticus

Runs a number of checks on staged files:

  • Fortran static analysis (e.g. empty constructors/destructors, duplicate variables in constructorAssign directives);
  • Fortran source formatting: runs scripts/aux/formatModuleUses.py and scripts/aux/formatDeclarations.py in --check mode over the staged content of source/**.{F90,Inc} (vendored code under source/external/ is excluded) and reports any file whose use or variable declaration blocks differ from the house style. Advisory only — it never blocks the commit, since most of the tree predates the formatters and reformatting is better made as a separate follow-up commit (skipped outside the main Galacticus repository);
  • 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, when yamllint is available);
  • parameter-file schema freshness: when a staged change could affect it (a Fortran source, the schema generator, the catalog builder, or the schema itself), regenerates schema/parameters.xsd and blocks the commit if the committed copy is stale (skipped outside the main Galacticus repository);
  • residual LaTeX in documentation: when a staged change could introduce it (a Fortran source, the docstring scanner, or its baseline), runs scripts/doc/convertDocstringsToRST.py --check-residual source and blocks the commit if LaTeX has appeared inside a region already converted to reStructuredText (skipped outside the main Galacticus repository);
  • test outcome markers: when a staged change touches a testSuite/{test,validate}-*.py script (or the auditor itself), runs scripts/aux/auditTestMarkers.py --check and blocks the commit if any script departs from the convention that a test signals failure with a FAILED: line and a zero exit, a pass with SUCCESS:, and a whole-test skip with SKIPPED: (skipped outside the main Galacticus repository);
  • compilation of Galacticus embedded XML and LaTeX fragments;
  • detection of leftover debugging statements (e.g. AJB HACK) in Perl, Fortran, and C/C++ sources.

01-claude-review

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).

prepare-commit-msg

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.

pre-push

The pre-push makes you confirm if you really, really want to push directly to the master|main branch - think twice before you do.....

License

Released under the MIT License.

About

Scripts used by git-hooks in Galacticus repos

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages