very-scary-scenario / nkd.su

A Neko Desu request robot.
https://nkd.su
Other
4 stars 2 forks source link

Precommit hook #278

Open homsar opened 10 months ago

homsar commented 10 months ago

This supersedes #240 and addresses #237

Based on discussions on Slack I suspect this may not be mergeable, but wanted to discuss anyway.

My priorities when implementing this were roughly prioritised as:

Things it checks:

All of these apart from the first two require creating a copy of the repo in a temporary directory to be able to remove any files that the linters shouldn't check without affecting any open file handles in the working directory. (This also helps avoid polluting the reflog.) If creating that fails, these tests are skipped. The directory is removed before the hook finishes, including if it is aborted with Ctrl+C.

This requires a non-zero amount of machinery, but significantly less than used by .pre-commit-config.yaml, and is what I would consider the minimal required to satisfactorily run linters in a pre-commit hook (in a way I would be willing to use in my workflow).