diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2018-09-26 16:50:07 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2018-09-26 20:43:21 +0200 |
commit | 4e16e2b17961075cd698ee5380941d5593a74e1a (patch) | |
tree | 4a729ae76f2e5677adca0b790e9da6f97eac67b4 /scripts/hooks/pre-push | |
parent | 8556019d203785f75795b1973a0ed380235cd954 (diff) | |
download | qtlocation-mapboxgl-4e16e2b17961075cd698ee5380941d5593a74e1a.tar.gz |
[build] add pre-push hook for checking code formatting
Diffstat (limited to 'scripts/hooks/pre-push')
-rwxr-xr-x | scripts/hooks/pre-push | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/hooks/pre-push b/scripts/hooks/pre-push new file mode 100755 index 0000000000..84bdafd70e --- /dev/null +++ b/scripts/hooks/pre-push @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +cd "$(git rev-parse --show-toplevel 2>/dev/null)" +HOOK=$(basename "${BASH_SOURCE[0]}") +source "scripts/hooks/common.sh" + +echo -n "Checking code formatting..." +RESULT=$(scripts/nitpick/format.js) +if [ ! -z "$RESULT" ]; then + echo -e " \033[1;31mChanged\033[0m" + echo -e -n "\033[1mDo you want to see the diff [y/N]?\033[0m " + read < /dev/tty + if [[ $REPLY =~ ^[Yy]$ ]]; then + echo "$RESULT" + echo "" + fi + + echo -e -n "\033[1mContinue to push? [Y/n]?\033[0m " + read < /dev/tty + if [[ $REPLY =~ ^[Nn]$ ]]; then + exit 1 + fi +else + echo -e " \033[32mOK\033[0m" +fi |