Skip to content

Commit 6bfceb4

Browse files
authored
Merge pull request #67 from davidferlay/pre-commit-hook-config-lang
Update Makefile for proper integration of git hooks script
2 parents f921d7b + 9f51ab3 commit 6bfceb4

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

Makefile

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Add utility functions and scripts to the container
22
include scripts/makefile/*.mk
33

4-
.PHONY: all provision si exec exec0 down clean dev info phpcs phpcbf drush cinsp
4+
.PHONY: all provision si exec exec0 down clean dev info phpcs phpcbf drush cinsp hooksymlink hookexec
55
.DEFAULT_GOAL := help
66

77
# https://stackoverflow.com/a/6273809/1826109
@@ -41,11 +41,9 @@ phpcsexec = docker run --rm \
4141
--ignore=*.css,libraries/*,dist/*,styleguide/* \
4242
.
4343

44-
$(info Installing git hooks)
45-
$(shell ln -sfn ../../scripts/git_hooks/pre-commit.sh .git/hooks/pre-commit)
4644

4745
## Full site install from the scratch
48-
all: | provision composer si info
46+
all: | provision composer si hooksymlink info
4947

5048
## Provision enviroment
5149
provision:
@@ -151,11 +149,31 @@ phpcs:
151149
phpcbf:
152150
@$(call phpcsexec, phpcbf)
153151

152+
## Add symbolic link from custom script(s) to /.git/hooks/pre-commit
153+
hooksymlink:
154+
ifneq ("$(wildcard scripts/git_hooks/pre-commit.sh)","")
155+
@echo "Installing git hooks"
156+
$(shell ln -sf ../../scripts/git_hooks/pre-commit.sh .git/hooks/pre-commit)
157+
else
158+
@echo "scripts/git_hooks/pre-commit.sh file does not exist"
159+
endif
160+
161+
## Execute git hooks
162+
hookexec:
163+
ifneq ("$(wildcard scripts/git_hooks/pre-commit.sh)","")
164+
@echo "Executing git hooks"
165+
@/bin/sh ./scripts/git_hooks/pre-commit.sh
166+
else
167+
@echo "scripts/git_hooks/pre-commit.sh file does not exist"
168+
endif
169+
170+
## Inspect configuration
154171
cinsp:
155172
@echo "Config schema validation..."
156173
@$(call php, drush -y en config_inspector)
157174
@$(eval SCHEMA_ERRORS = $(shell docker-compose exec -T --user $(CUID):$(CGID) php drush inspect_config --only-error))
158175
@$(call php, drush -y pmu config_inspector)
159176
@if [ ! -z "$(SCHEMA_ERRORS)" ]; then echo "Error(s) in config schemas"; exit 1; fi
160177

178+
## Full inspection
161179
insp: | cinsp phpcs

0 commit comments

Comments
 (0)