Zettelkasten
Wonko's collection of notes

Posted on , in Unix, tagged with ,

Zola pre-push hook

I commit the generated site files into my blog's repo because that is the easiest way to get github to host it for me. In order to not forget to build, I wanted a hook that reminds me before I push.

Running zola build alone isn't enough, as it doesn't give an error return code or modify one of the files to be pushed. git diff doesn't normally have a return code to indicate if there are diffs, but git diff --quiet does. Combining both will build and then fail, if anything in docs/ isn't added or committed.

zola build && git diff --quiet docs/

To include this in a pre-commit config, wrap it in bash -c and use as a system hook. Check out me .pre-commit-config.yaml.