diff --git a/prevent_commit_to_main.sh b/prevent_commit_to_main.sh index 5237b16a..01f8d241 100755 --- a/prevent_commit_to_main.sh +++ b/prevent_commit_to_main.sh @@ -1,9 +1,14 @@ -#!/bin/sh +#!/usr/bin/env sh ##!"C:\\Program Files\\Git\\usr\\bin\\bash.exe" branch="$(git rev-parse --abbrev-ref HEAD)" if [ "$branch" = "main" ]; then -echo "You are on the main branch. Committing to the main branch is not allowed." -exit 1 + if [ -z "${GIT_DIR}/MERGE_MODE" ]; then + echo "Merge to main allowed." + exit 0 + else + echo "You are on the main branch. Committing to the main branch is not allowed." + exit 1 + fi fi