commit
4bc88f2ac2
2 changed files with 42 additions and 0 deletions
34
.githooks/pre-commit
Executable file
34
.githooks/pre-commit
Executable 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
|
|
@ -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
|
||||
```
|
Loading…
Reference in a new issue