File tree Expand file tree Collapse file tree 2 files changed +38
-18
lines changed
Expand file tree Collapse file tree 2 files changed +38
-18
lines changed Original file line number Diff line number Diff line change 11
2- # VARIABLES #
2+ # DEPENDENCIES #
33
4- # Define the command to copy files:
5- CP ?= cp
6-
7- # Define the command for setting executable permissions:
8- MAKE_EXECUTABLE ?= chmod +x
9-
10- # Define the destination directory for git hooks:
11- GIT_HOOKS_DIR ?= $(ROOT_DIR ) /.git/hooks
12-
13- # Define the directory from which to copy git hooks:
14- TOOLS_GIT_HOOKS_DIR ?= $(TOOLS_DIR ) /git/hooks
15-
16- # Define the path of the `git pre-push` hook:
17- GIT_HOOK_PRE_PUSH ?= pre-push
4+ include $(TOOLS_MAKE_LIB_DIR ) /init/git_hooks.mk
185
196
207# TARGETS #
@@ -23,9 +10,7 @@ GIT_HOOK_PRE_PUSH ?= pre-push
2310#
2411# This target performs initialization tasks, such as installing git hooks, etc.
2512
26- init :
27- @$(CP ) $(TOOLS_GIT_HOOKS_DIR ) /$(GIT_HOOK_PRE_PUSH ) $(GIT_HOOKS_DIR )
28- @$(MAKE_EXECUTABLE ) $(GIT_HOOKS_DIR ) /$(GIT_HOOK_PRE_PUSH )
13+ init : init-git-hooks
2914
3015.PHONY : init
3116
Original file line number Diff line number Diff line change 1+
2+ # VARIABLES #
3+
4+ # Define the command to copy files:
5+ CP ?= cp
6+
7+ # Define the command for setting executable permissions:
8+ MAKE_EXECUTABLE ?= chmod +x
9+
10+ # Define the directory from which to copy git hooks:
11+ GIT_HOOKS_DIR ?= $(TOOLS_DIR ) /git/hooks
12+
13+ # Define a list of hooks:
14+ GIT_HOOKS ?= $(shell find $(GIT_HOOKS_DIR ) -type f | xargs -n 1 basename)
15+
16+ # Define the destination directory for git hooks:
17+ GIT_HOOKS_OUT ?= $(ROOT_DIR ) /.git/hooks
18+
19+
20+ # TARGETS #
21+
22+ # Installs git hooks.
23+ #
24+ # This target installs [git hooks][1].
25+ #
26+ # [1]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
27+
28+ init-git-hooks :
29+ @for file in $(GIT_HOOKS ) ; do \
30+ $(CP ) $(GIT_HOOKS_DIR ) /$$ file $(GIT_HOOKS_OUT ) /$$ file; \
31+ $(MAKE_EXECUTABLE ) $(GIT_HOOKS_OUT ) /$$ file; \
32+ done
33+
34+ .PHONY : init-git-hooks
35+
You can’t perform that action at this time.
0 commit comments