1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00

Merge pull request #599 from dark64/git-hooks

Add git pre-commit hook
This commit is contained in:
Thibaut Schaeffer 2020-05-14 23:28:24 +02:00 committed by GitHub
commit 4bc88f2ac2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 0 deletions

34
.githooks/pre-commit Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
log () {
printf "[\033[1;37mpre-commit\033[0m] $1\n"
}
rustfmt +nightly --version &>/dev/null
if [ $? != 0 ]; then
log "\033[0;33mWARN\033[0m: rustfmt +nightly not found, skipping pre-commit hook"
exit 0
fi
files=()
for file in $(git diff --name-only --cached); do
if [ ${file: -3} == ".rs" ]; then
rustfmt +nightly --check $file &>/dev/null
if [ $? != 0 ]; then
files+=($file)
fi
fi
done
if [ -n "$files" ]; then
log "the following files have improper formatting:\n"
for file in "${files[@]}"; do
printf "\033[0;33m\t$file\n"
done
printf "\n\033[0m"
log "aborting commit"
exit 1
fi
exit 0

View file

@ -37,3 +37,11 @@ ZoKrates is released under the GNU Lesser General Public License v3.
We happily welcome contributions. You can either pick an existing issue or reach out on [Gitter](https://gitter.im/ZoKrates/Lobby).
Unless you explicitly state otherwise, any contribution you intentionally submit for inclusion in the work shall be licensed as above, without any additional terms or conditions.
### Git Hooks
You can enable zokrates git hooks locally by running:
```sh
git config core.hooksPath .githooks
```