StyleCheck as pre-commit hook
The other day I changed the CheckBasicStyle.lua script so that it can check individual files and even the files specifically being committed in Git. This comes handy as a git pre-commit hook - whenever you commit to git, CheckBasicStyle will check your commit before allowing you to actually commit it.

To enable:
Go to your .git/hooks folder, create a text file "pre-commit" there with the following contents:

# Redirect output to stderr:
exec 1>&2

# Check the style of the files being committed:
exec src/CheckBasicStyle.lua -g
On unix-like systems, you need to set the file as executable (chmod +x)
This is all it should take. If you want to disable the checks, just rename / remove the file.

I've found one problem so far, but I consider it a highly unlikely scenario:
If you edit a file, stage it for commit, then edit it again and finally commit, Git will commit the staged version, while CheckBasicStyle will check the edited version.
Thanks given by: NiLSPACE , LogicParrot , satoshinm

Users browsing this thread: 1 Guest(s)