Created
May 24, 2016 19:51
-
-
Save arlaneenalra/a26aa9abc3d7e6f1191132a209792ccb to your computer and use it in GitHub Desktop.
A few interesting make targets for phpcs ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get-branch: | |
# make sure that origin pointers are up to date | |
@git fetch | |
$(eval BRANCH = "$(shell git rev-parse --abbrev-ref HEAD)") | |
$(eval MERGE_BASE = "$(shell git merge-base $(BRANCH) origin/develop)") | |
# all committed changes | |
$(eval FILES_COMMITTED = $(shell git diff --name-only $(MERGE_BASE))) | |
# all uncommitted changes | |
$(eval FILES_UNCOMMITTED = $(shell git status --porcelain -u | sed 's/->//' | sed 's/^...//')) | |
# combined and filter | |
$(eval FILES_RAW = $(filter %.php, $(FILES_COMMITTED) $(FILES_UNCOMMITTED))) | |
# Make sure all modified files still exist! | |
$(eval FILES = $(sort $(shell for f in ${FILES_RAW} ; do if [ -f "./$$f" ] ; then FILES="$$FILES $$f" ; fi done ; echo $$FILES ))) | |
@echo "Processing: $(FILES)" | |
test-format: | |
@echo "Checking code formatting..." | |
@$(PHP_CS) --standard=build/coding-standard.xml --warning-severity=0 -s $(FILES) | |
test-format-branch: get-branch | |
@if [ "$(FILES)" == "" ] ; then \ | |
echo "Nothing to do." ; \ | |
else \ | |
$(MAKE) test-format FILES="$(FILES)" ; \ | |
fi | |
fix-format: | |
@echo "Fixing code formatting..." | |
@$(PHP_CBF) --standard=build/coding-standard.xml --warning-severity=0 $(FILES) | |
fix-format-branch: get-branch | |
@if [ "$(FILES)" == "" ] ; then \ | |
echo "Nothing to do." ; \ | |
else \ | |
$(MAKE) fix-format FILES="$(FILES)" ; \ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment