From 4f2cac2668f1cb174296b3a38dba5bef504fda5f Mon Sep 17 00:00:00 2001 From: Michael Matloka Date: Fri, 24 May 2024 12:57:54 +0200 Subject: [PATCH] chore(dev): Add pre-push hook to confirm pushing to master (#22490) * chore(dev): Add pre-push hook to confirm pushing to master * Prohibit direct pushes completely --- .husky/pre-push | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 .husky/pre-push diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100755 index 00000000000..fdebad3f174 --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,13 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +protected_branch='master' +current_branch=$(git branch --show-current) + +if [ $protected_branch = $current_branch ] +then + echo "Pushing to $protected_branch is a sin! Instead, create a pull request and repent." + exit 1 # push will not execute +else + exit 0 # push will execute +fi