I need a tool that slaps me with a "you fool, you can't commit a bugfix without implementing a test case for the bug" whenever I try to make a commit that contains the word "fix" and no file in the tests directory changed
@Aran-Fey have you tried that? Because as far as I know the pre-commit runs before you get a chance to phrase the commit message. You'd want the commit-msg hook, and when that runs you get the commit message in $1. And if you want to subvert either of those hooks due to false positives, you can do git commit --no-verify, same goes for merges where the message is auto-generated.
I could be wrong but the domain starts with chatgpt so...
And it would probably be more robust (read: paranoid) to work with something like git diff --cached --name-only --diff-filter=d -z | grep -qz '^tests/' assuming git bash supports all these. --diff-filter=d excludes deleted files (so that just deleting a test doesn't skip the hook), the -z flags ensure that you can handle zalgo in paths, and there's really no reason to catch a variable and echo it back if you can just pipe. Oh, and I'd definitely anchor the regex at the start.
But I didn't test any of this.
Odds are you can also use -v with grep to invert the match and avoid having to negate the result in sh.