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/common.sh | |
parent | 8556019d203785f75795b1973a0ed380235cd954 (diff) | |
download | qtlocation-mapboxgl-4e16e2b17961075cd698ee5380941d5593a74e1a.tar.gz |
[build] add pre-push hook for checking code formatting
Diffstat (limited to 'scripts/hooks/common.sh')
-rw-r--r-- | scripts/hooks/common.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/hooks/common.sh b/scripts/hooks/common.sh new file mode 100644 index 0000000000..4d333689f8 --- /dev/null +++ b/scripts/hooks/common.sh @@ -0,0 +1,23 @@ +if [ "$1" = '--install' ]; then + mkdir -p ".git/hooks" + if [ -e ".git/hooks/$HOOK" ] || [ -L ".git/hooks/$HOOK" ]; then + if [ "$(readlink .git/hooks/$HOOK)" != "scripts/hooks/$HOOK" ]; then + echo "Can't install $HOOK because it has custom content" + else + echo "$HOOK hook is already installed" + fi + exit 1 + fi + echo "Installing $HOOK hook" + ln -s ../../scripts/hooks/$HOOK .git/hooks/$HOOK + exit 0 +elif [ "$1" = '--uninstall' ]; then + if [ "$(readlink .git/hooks/$HOOK)" = "scripts/hooks/$HOOK" ]; then + echo "Removing $HOOK hook" + rm .git/hooks/$HOOK + exit 0 + else + echo "$HOOK hook is not installed" + exit 1 + fi +fi |