Skip to content

Commit 0bd1524

Browse files
committed
Copy pre-commit hook to real GIT_DIR
This is not always ".git" - for example, if this repository is a submodule or worktree, or if $GIT_DIR is set explicitly.
1 parent ffa4136 commit 0bd1524

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ SHELL=/bin/bash
44

55
STATIC_ANALYSIS_CHECKER := $(shell which shellcheck 2> /dev/null)
66
LINTER_CHECKER := $(shell which ec 2> /dev/null)
7+
GIT_DIR = $(shell git rev-parse --git-dir 2> /dev/null)
78

89
OS:=
910
ifeq ($(OS),Windows_NT)
@@ -72,7 +73,7 @@ env/example:
7273

7374
pre_commit/install:
7475
@echo "Installing pre-commit hooks"
75-
cp $(PRE_COMMIT_SCRIPTS_FILE) ./.git/hooks/
76+
cp $(PRE_COMMIT_SCRIPTS_FILE) $(GIT_DIR)/hooks/
7677

7778
pre_commit/run: test sa lint env/example
7879

0 commit comments

Comments
 (0)