From 175d7f95f54b23e2f0ee0f2746780f2296c597d8 Mon Sep 17 00:00:00 2001 From: Alan Buscaglia Date: Tue, 2 Dec 2025 13:42:04 +0100 Subject: [PATCH] fix: clear core.hooksPath before installing pre-commit hooks (#9413) --- scripts/setup-git-hooks.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/setup-git-hooks.sh b/scripts/setup-git-hooks.sh index 2006918b0f..ab7c01479d 100755 --- a/scripts/setup-git-hooks.sh +++ b/scripts/setup-git-hooks.sh @@ -18,13 +18,13 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━ echo "" # Check if we're in a git repository -if ! git rev-parse --git-dir > /dev/null 2>&1; then +if ! git rev-parse --git-dir >/dev/null 2>&1; then echo -e "${RED}❌ Not in a git repository${NC}" exit 1 fi # Check if Poetry is installed -if ! command -v poetry &> /dev/null; then +if ! command -v poetry &>/dev/null; then echo -e "${RED}❌ Poetry is not installed${NC}" echo -e "${YELLOW} Install Poetry: https://python-poetry.org/docs/#installation${NC}" exit 1 @@ -46,6 +46,12 @@ else fi echo "" +# Clear any existing core.hooksPath to avoid pre-commit conflicts +if git config --get core.hooksPath >/dev/null 2>&1; then + echo -e "${YELLOW}🧹 Clearing existing core.hooksPath configuration...${NC}" + git config --unset-all core.hooksPath +fi + echo -e "${YELLOW}🔗 Installing pre-commit hooks...${NC}" poetry run pre-commit install