mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
- Add pre-commit hook script to misc/scripts
- Refer to it in CONTRIBUTING.md - Add setup note in docs folder
This commit is contained in:
18
misc/scripts/pre-commit
Normal file
18
misc/scripts/pre-commit
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
exec 1>&2
|
||||
exitVal=0
|
||||
while read -r f
|
||||
do
|
||||
filename="${f##*/}"
|
||||
extension="${filename##*.}"
|
||||
p="$PWD/$f";
|
||||
if [[ -f "$p" ]] && { [ "$extension" == "ql" ] || [ "$extension" == "qll" ]; }
|
||||
then
|
||||
if ! codeql query format --check-only "$p"
|
||||
then
|
||||
exitVal=1
|
||||
fi
|
||||
fi
|
||||
done <<<"$(git diff --cached --relative --name-only)"
|
||||
exit $exitVal
|
||||
Reference in New Issue
Block a user