From 95ffee9af051380566f435b6cf64e4427f4411bb Mon Sep 17 00:00:00 2001 From: Lucas Raposeiras Date: Wed, 11 Sep 2024 13:46:41 +0200 Subject: [PATCH] fix(husky): pre-commit hook not working for new projects --- .husky/commit-msg | 3 --- .husky/pre-commit | 4 +--- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index 5cbe3ee9..66ae5b57 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - pnpm commitlint --edit $1 \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit index da568387..e7da137a 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,5 +1,3 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" . "$(dirname "$0")/common.sh" @@ -7,7 +5,7 @@ echo "===\n>> Checking branch name..." # Check if branch protection is enabled if [[ -z $SKIP_BRANCH_PROTECTION ]]; then - BRANCH=$(git rev-parse --abbrev-ref HEAD) + BRANCH=$(git branch --show-current) PROTECTED_BRANCHES="^(main|master)" if [[ $BRANCH =~ $PROTECTED_BRANCHES ]]; then