adding git hooks
This commit is contained in:
parent
bfbc8001ee
commit
0ecb515b1f
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/env bash
|
||||||
|
|
||||||
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
GIT_DIR=$CURRENT_DIR/../.git
|
||||||
|
GIT_HOOKS_DIR=$GIT_DIR/hooks
|
||||||
|
|
||||||
|
rm -rf "$GIT_HOOKS_DIR"
|
||||||
|
ln -s "$CURRENT_DIR" "$GIT_HOOKS_DIR"
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/env bash
|
||||||
|
|
||||||
|
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
if [[ ${current_branch} != "master" ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Pushing to master? Let me run some pre-push hooks ..."
|
||||||
|
|
||||||
|
grep_debug='git grep -n "debug.sh" -- *.sh'
|
||||||
|
grep_log_calls='git grep -n "log " -- *.sh'
|
||||||
|
WHITE_LIST_SCRIPTS="^(\\.git-hooks)"
|
||||||
|
include_debug_count=$(eval "$grep_debug" | grep -v $WHITE_LIST_SCRIPTS | wc -l)
|
||||||
|
log_calls_count=$(eval "$grep_log_calls" | grep -v $WHITE_LIST_SCRIPTS | wc -l)
|
||||||
|
|
||||||
|
if [[ $((include_debug_count + log_calls_count)) -gt 1 ]]; then
|
||||||
|
echo "Remove debug traces!"
|
||||||
|
echo ""
|
||||||
|
eval "$grep_debug" > /dev/stdout
|
||||||
|
eval "$grep_log_calls" > /dev/stdout
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO for some reason, tests fail when ran from pre-push hook ( WTF? )
|
||||||
|
if [[ -z $I_ASSURE_YOU_TESTS_ARE_PASSING ]]; then
|
||||||
|
echo ""
|
||||||
|
echo "Run ./test/run.sh before pushing to master. Then set I_ASSURE_YOU_TESTS_ARE_PASSING variable to bypass this" | fold -sw 80
|
||||||
|
exit 1
|
||||||
|
fi
|
Loading…
Reference in New Issue