Git hooks¶
The FastSurfer team has developed a pre-commit hook script to help implement Continuous Development and Testing. This CI/CD expands on github workflows executing them locally. They require a local uv installation as described for FastSurfer’s installation from source.
Pre-commit Hook¶
The pre-commit hook script will (ignoring files that are git-ignored):
Check for non-ASCII file names being added (allow them with
git config hooks.allownonascii true)Check for trailing white spaces in files
Run the lint tests in
test/lint, like the code-style workflowSync the uv environment with the
styleanddocextras (uv sync --inexact); the following checks start once it is in syncRun ruff to verify python code formatting is valid
Run codespell to check the spelling
Run the unit tests in
test/image,test/shellandtest/utils, like the unittest workflow, but in 4 (optimal choice, 09-2026) parallel pytest-xdist workers (pytest and pytest-xdist are added withuv run --with)Run sphinx-build to rebuild the documentation into
FastSurfer/doc-build.Here, one important caveat for documentation editors is that sphinx-build may fail if the documentation file structure is changed, without first cleaning the autosummary/autodoc-generated files. To do this, delete the following directory
FastSurfer/doc/api/generated.
The checks run in parallel. A passed check prints one line; the output of a failed check is printed as one block
when it finishes. The output of all checks is saved in $TMPDIR/fastsurfer-pre-commit-<uid>-<checksum>.log, the
summary names the file, and the next run overwrites it. The summary lists the status and run time of every check.
All checks run to completion, and any failed check blocks the commit; git commit --no-verify skips the hook.
Ctrl-C stops all running checks.
Installation¶
To install the pre-commit hook, in the FastSurfer directory call
ln -s ../../tools/git-hooks/pre-commit .git/hooks/pre-commit