Rainbond/precheck.sh

29 lines
403 B
Bash
Raw Permalink Normal View History

2019-08-04 21:29:33 +08:00
#!/bin/sh
2019-08-30 17:05:03 +08:00
STAGED_GO_FILES=$(git diff --cached --name-only | grep ".go$")
2019-08-04 21:29:33 +08:00
if [[ "$STAGED_GO_FILES" = "" ]]; then
exit 0
fi
PASS=true
for FILE in $STAGED_GO_FILES
do
goimports -w $FILE
golangci-lint run --fix --disable=typecheck $FILE
if [[ $? != 0 ]]; then
PASS=false
fi
done
if ! $PASS; then
printf "COMMIT FAILED\n"
exit 1
else
printf "COMMIT SUCCEEDED\n"
git add
fi
2019-08-30 17:00:49 +08:00
exit 0