Skip to content

Commit

Permalink
Merge pull request #67 from davidferlay/pre-commit-hook-config-lang
Browse files Browse the repository at this point in the history
Update Makefile for proper integration of git hooks script
  • Loading branch information
jbguerraz authored Apr 10, 2019
2 parents f921d7b + 9f51ab3 commit 6bfceb4
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Add utility functions and scripts to the container
include scripts/makefile/*.mk

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

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

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

## Full site install from the scratch
all: | provision composer si info
all: | provision composer si hooksymlink info

## Provision enviroment
provision:
Expand Down Expand Up @@ -151,11 +149,31 @@ phpcs:
phpcbf:
@$(call phpcsexec, phpcbf)

## Add symbolic link from custom script(s) to /.git/hooks/pre-commit
hooksymlink:
ifneq ("$(wildcard scripts/git_hooks/pre-commit.sh)","")
@echo "Installing git hooks"
$(shell ln -sf ../../scripts/git_hooks/pre-commit.sh .git/hooks/pre-commit)
else
@echo "scripts/git_hooks/pre-commit.sh file does not exist"
endif

## Execute git hooks
hookexec:
ifneq ("$(wildcard scripts/git_hooks/pre-commit.sh)","")
@echo "Executing git hooks"
@/bin/sh ./scripts/git_hooks/pre-commit.sh
else
@echo "scripts/git_hooks/pre-commit.sh file does not exist"
endif

## Inspect configuration
cinsp:
@echo "Config schema validation..."
@$(call php, drush -y en config_inspector)
@$(eval SCHEMA_ERRORS = $(shell docker-compose exec -T --user $(CUID):$(CGID) php drush inspect_config --only-error))
@$(call php, drush -y pmu config_inspector)
@if [ ! -z "$(SCHEMA_ERRORS)" ]; then echo "Error(s) in config schemas"; exit 1; fi

## Full inspection
insp: | cinsp phpcs

0 comments on commit 6bfceb4

Please sign in to comment.