From 1f46c711f259f0baa41767b14ad88995d266b667 Mon Sep 17 00:00:00 2001
From: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Date: Thu, 5 Aug 2021 14:58:40 +0200
Subject: [PATCH] chore: soft-block commits to main branch with husky
 pre-commit check (#11094)

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
---
 .husky/pre-commit | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/.husky/pre-commit b/.husky/pre-commit
index f3a6796048..3c1529dccd 100755
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -2,3 +2,19 @@
 . "$(dirname "$0")/_/husky.sh"
 
 yarn pretty-quick --staged
+
+BRANCH_NAME=$(git branch --show-current)
+
+if [ "$BRANCH_NAME" = "main" ]; then
+  echo
+  echo "Aborting commit."
+  echo "You're committing to the main branch, usually this is not what you want to do."
+  echo "Did you forget to make a new feature branch to put your work on?"
+  echo
+  echo "Use git checkout -b <new_branch> to create a new feature branch."
+  echo
+  echo "If you're sure you want to commit to the main branch, run git commit with the --no-verify flag."
+  echo
+
+  exit 1
+fi
-- 
GitLab