chore(build): Ensure git hooks from Makefile

This commit is contained in:
Zaiming Shi 2021-03-06 07:39:48 +01:00
parent cc5baabd06
commit 3e3c06118c
3 changed files with 26 additions and 0 deletions

View File

@ -1,3 +1,4 @@
$(shell scripts/git-hooks-init.sh)
REBAR_VERSION = 3.14.3-emqx-4 REBAR_VERSION = 3.14.3-emqx-4
REBAR = $(CURDIR)/rebar3 REBAR = $(CURDIR)/rebar3
BUILD = $(CURDIR)/build BUILD = $(CURDIR)/build

12
scripts/git-hook-pre-push.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
set -euo pipefail
url="$2"
if [ -f 'EMQX_ENTERPRISE' ]; then
if [[ "$url" != *emqx-enterprise* ]]; then
echo "$(tput setaf 1)error: enterprise_code_to_non_enterprise_repo"
exit 1
fi
fi

13
scripts/git-hooks-init.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
set -euo pipefail
if [ ! -d .git ]; then
exit 0
fi
mkdir -p ".git/hooks"
if [ ! -L '.git/hooks/pre-push' ]; then
ln -sf '../../scripts/git-hook-pre-push.sh' '.git/hooks/pre-push'
fi