From 1eeb3298b9c9a31507c0630817f19c39eb9b17f6 Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Thu, 1 Jun 2023 09:36:20 -0500 Subject: [PATCH] repo: block pushing to release branches in git hook (#17377) --- dev/hooks/pre-push | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dev/hooks/pre-push b/dev/hooks/pre-push index 76d99a593..83168fdeb 100755 --- a/dev/hooks/pre-push +++ b/dev/hooks/pre-push @@ -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