This uses babashka tasks to run some pre-commit checks via git hooks, but only after you opt in by running bb run git-hooks install. Currently it runs cljfmt and clj-kondo and rejects the commit if either complain. In my testing this runs in tens of milliseconds so hopefully worth the added value to each commit.
Currently it only checks files that are staged, and crucially, it checks the staged version of those files in a separate tmp dir (every example of git hooks I saw online checked the working directory version of the staged files; which are often not the same!). If we find a need to have the other un-staged files in there too, I can add that. I wasn't sure if it made a difference or not.
It is currently depending on a fork of cljfmt because it didn't have a library fn to pass in paths to recursively check. I'm going to PR that upstream and see if I can get it or something similar into an official release.
This is all towards the goal of spending less time fixing bugs that sneak onto main and wasting time cleaning up conflicts that are merely due to inconsistent code formatting. We had been doing far too much of the latter, especially.
This uses babashka tasks to run some pre-commit checks via git hooks, but only after you opt in by running
bb run git-hooks install
. Currently it runs cljfmt and clj-kondo and rejects the commit if either complain. In my testing this runs in tens of milliseconds so hopefully worth the added value to each commit.Currently it only checks files that are staged, and crucially, it checks the staged version of those files in a separate tmp dir (every example of git hooks I saw online checked the working directory version of the staged files; which are often not the same!). If we find a need to have the other un-staged files in there too, I can add that. I wasn't sure if it made a difference or not.
It is currently depending on a fork of cljfmt because it didn't have a library fn to pass in paths to recursively check. I'm going to PR that upstream and see if I can get it or something similar into an official release.
This is all towards the goal of spending less time fixing bugs that sneak onto
main
and wasting time cleaning up conflicts that are merely due to inconsistent code formatting. We had been doing far too much of the latter, especially.