mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
repo: block pushing to release branches in git hook (#17377)
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
fail () {
|
||||
echo "pre-push hook: $@" >&2
|
||||
echo " --no-verify to bypass this hook" >&2
|
||||
@@ -13,15 +16,19 @@ if [ "$2" != "$ent" -a -f version/version_ent.go ]; then
|
||||
fail "found enterprise version file version/version_ent.go while pushing to oss remote"
|
||||
fi
|
||||
|
||||
# don't push to main, stable-*
|
||||
# do not push directly to main, stable-*, release/*
|
||||
# ====================
|
||||
while read local_ref local_sha remote_ref remote_sha
|
||||
do
|
||||
if [ "$remote_ref" = "refs/heads/main" ]; then
|
||||
fail "refusing to push directly to main"
|
||||
fail "refusing to push directly to main"
|
||||
fi
|
||||
|
||||
if echo "$remote_ref"|grep -q 'refs/heads/stable-.*'; then
|
||||
fail "refusing to push directly to a branch prefixed \`stable-\`"
|
||||
fail "refusing to push directly to a branch prefixed \`stable-\`"
|
||||
fi
|
||||
|
||||
if echo "$remote_ref"|grep -q 'refs/heads/release/.*'; then
|
||||
fail "refusing to push directly to a branch prefixed \`release/\`"
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user