2017-08-17 17:55:53 +00:00
|
|
|
#!/bin/sh
|
2019-04-17 22:27:50 +00:00
|
|
|
fail () {
|
|
|
|
echo "pre-push hook: $@" >&2
|
|
|
|
echo " --no-verify to bypass this hook" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
2017-08-17 17:55:53 +00:00
|
|
|
|
2019-04-17 22:27:50 +00:00
|
|
|
# only push to oss when the enterprise version is absent
|
|
|
|
# ====================
|
|
|
|
oss="git@github.com:/hashicorp/nomad"
|
|
|
|
ent="git@github.com:/hashicorp/nomad-enterprise"
|
|
|
|
if [ "$2" != "$ent" -a -f version/version_ent.go ]; then
|
|
|
|
fail "found enterprise version file version/version_ent.go while pushing to oss remote"
|
2017-08-17 17:55:53 +00:00
|
|
|
fi
|
|
|
|
|
2019-04-17 22:27:50 +00:00
|
|
|
# don't push to master, stable-*
|
|
|
|
# ====================
|
|
|
|
while read local_ref local_sha remote_ref remote_sha
|
|
|
|
do
|
|
|
|
if [ "$remote_ref" = "refs/heads/master" ]; then
|
|
|
|
fail "refusing to push directly to master"
|
|
|
|
fi
|
2017-08-17 17:55:53 +00:00
|
|
|
|
2019-04-17 22:27:50 +00:00
|
|
|
if echo "$remote_ref"|grep -q 'refs/heads/stable-.*'; then
|
|
|
|
fail "refusing to push directly to a branch prefixed \`stable-\`"
|
|
|
|
fi
|
|
|
|
done
|