From 6c8165601d3092d932212d0ed2c1756a45c5e5a7 Mon Sep 17 00:00:00 2001 From: munja Date: Tue, 7 Dec 2021 16:58:23 +0000 Subject: [PATCH] chore: adding hook script to prevent accidental commits to master --- .git-hooks/pre-commit | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index f592f8a..382524a 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -1,2 +1,11 @@ #!/bin/sh -sasjs lint \ No newline at end of file +sasjs lint + +# Avoid commits to the master branch +BRANCH=`git rev-parse --abbrev-ref HEAD` + +if [[ "$BRANCH" =~ ^(master|main|develop)$ ]]; then + echo "You are on branch $BRANCH. Are you sure you want to commit to this branch?" + echo "If so, commit with -n to bypass the pre-commit hook." + exit 1 +fi \ No newline at end of file