| 1 |
#!/usr/bin/env bash |
| 2 |
# Detect if any files have changed in the git repository. Output an appropriate |
| 3 |
# error message if they have changed. |
| 4 |
|
| 5 |
if [[ -n $(git status -s) ]]; then |
| 6 |
git diff --minimal HEAD |
| 7 |
echo |
| 8 |
echo "**************************************************" |
| 9 |
case "$1" in |
| 10 |
"proto") |
| 11 |
echo "* .pb.go files and .proto files are out of sync. *" |
| 12 |
echo "* Run \"make gen\" to generate them. *" |
| 13 |
;; |
| 14 |
"format") |
| 15 |
echo "* C or Go files have incorrect formatting. *" |
| 16 |
echo "* Run \"make format\" to fix them. *" |
| 17 |
;; |
| 18 |
*) |
| 19 |
echo "* Files have changed in this repository. *" |
| 20 |
;; |
| 21 |
esac |
| 22 |
echo "**************************************************" |
| 23 |
git reset HEAD --hard |
| 24 |
exit 1 |
| 25 |
fi |