-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
375 changed files
with
972 additions
and
167,303 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# - 'composer update' if changed composer.json | ||
|
||
ESC_SEQ="\x1b[" | ||
COL_RESET=$ESC_SEQ"39;49;00m" | ||
COL_RED=$ESC_SEQ"0;31m" | ||
COL_GREEN=$ESC_SEQ"0;32m" | ||
COL_YELLOW=$ESC_SEQ"0;33m" | ||
|
||
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)" | ||
|
||
check_run() { | ||
echo "$changed_files" | grep -q "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2" | ||
} | ||
|
||
check_run composer.json "composer update" | ||
exit 0 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# - 'composer update' if changed composer.json | ||
|
||
ESC_SEQ="\x1b[" | ||
COL_RESET=$ESC_SEQ"39;49;00m" | ||
COL_RED=$ESC_SEQ"0;31m" | ||
COL_GREEN=$ESC_SEQ"0;32m" | ||
COL_YELLOW=$ESC_SEQ"0;33m" | ||
|
||
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)" | ||
|
||
check_run() { | ||
echo "$changed_files" | grep -q "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2" | ||
} | ||
|
||
check_run composer.json "composer update" | ||
exit 0 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
# Lint all added php-files via 'php -l' | ||
|
||
ROOT_DIR="$(pwd)/" | ||
LIST=$(git diff-index --cached --name-only --diff-filter=ACMR HEAD) | ||
ERRORS_BUFFER="" | ||
ESC_SEQ="\x1b[" | ||
COL_RESET=$ESC_SEQ"39;49;00m" | ||
COL_RED=$ESC_SEQ"0;31m" | ||
COL_GREEN=$ESC_SEQ"0;32m" | ||
COL_YELLOW=$ESC_SEQ"0;33m" | ||
COL_BLUE=$ESC_SEQ"0;34m" | ||
COL_MAGENTA=$ESC_SEQ"0;35m" | ||
COL_CYAN=$ESC_SEQ"0;36m" | ||
|
||
echo | ||
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-commit hook: \"php-linter\"" | ||
|
||
for file in $LIST | ||
do | ||
EXTENSION=$(echo "$file" | grep -E ".php$|.module$|.inc$|.install$") | ||
if [ "$EXTENSION" != "" ]; then | ||
ERRORS=$(php -l $ROOT_DIR$file 2>&1 | grep "Parse error") | ||
if [ "$ERRORS" != "" ]; then | ||
if [ "$ERRORS_BUFFER" != "" ]; then | ||
ERRORS_BUFFER="$ERRORS_BUFFER\n$ERRORS" | ||
else | ||
ERRORS_BUFFER="$ERRORS" | ||
fi | ||
echo "Syntax errors found in file: $file " | ||
fi | ||
fi | ||
done | ||
if [ "$ERRORS_BUFFER" != "" ]; then | ||
echo | ||
echo "These errors were found in try-to-commit files: " | ||
echo -e $ERRORS_BUFFER | ||
echo | ||
printf "$COL_RED%s$COL_RESET\r\n\r\n" "Can't commit, fix errors first." | ||
exit 1 | ||
else | ||
echo "Okay" | ||
exit 0 | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
|
||
# Check code style via '.php-cs-fixer.php' | ||
|
||
EXECUTABLE_NAME=php-cs-fixer | ||
EXECUTABLE_COMMAND=fix | ||
CONFIG_FILE=.php-cs-fixer.php | ||
CONFIG_FILE_PARAMETER='--config' | ||
ROOT=`pwd` | ||
ESC_SEQ="\x1b[" | ||
COL_RESET=$ESC_SEQ"39;49;00m" | ||
COL_RED=$ESC_SEQ"0;31m" | ||
COL_GREEN=$ESC_SEQ"0;32m" | ||
COL_YELLOW=$ESC_SEQ"0;33m" | ||
COL_BLUE=$ESC_SEQ"0;34m" | ||
COL_MAGENTA=$ESC_SEQ"0;35m" | ||
COL_CYAN=$ESC_SEQ"0;36m" | ||
|
||
echo "" | ||
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-commit hook: \"php-cs-fixer\"" | ||
|
||
# possible locations | ||
locations=( | ||
$ROOT/bin/$EXECUTABLE_NAME | ||
$ROOT/vendor/bin/$EXECUTABLE_NAME | ||
) | ||
|
||
for location in ${locations[*]} | ||
do | ||
if [[ -x $location ]]; then | ||
EXECUTABLE=$location | ||
break | ||
fi | ||
done | ||
|
||
if [[ ! -x $EXECUTABLE ]]; then | ||
echo "executable $EXECUTABLE_NAME not found, exiting..." | ||
echo "if you're sure this is incorrect, make sure they're executable (chmod +x)" | ||
exit | ||
fi | ||
|
||
echo "using \"$EXECUTABLE_NAME\" located at $EXECUTABLE" | ||
$EXECUTABLE --version | ||
|
||
if [[ -f $ROOT/$CONFIG_FILE ]]; then | ||
CONFIG=$ROOT/$CONFIG_FILE | ||
echo "config file located at $CONFIG loaded" | ||
fi | ||
|
||
FILES=`git status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | sed -e "s/_ide_helper.php$//" | sed -e "s/_ide_helper_models.php$//" | sed -e "s/.phpstorm.meta.php$//" | tr '\n' ' ' | sed 's/ *$//g'` | ||
if [ -z "$FILES" ]; then | ||
echo "No php files found to fix." | ||
else | ||
echo "Fixing files ${FILES} in project"; | ||
if [[ -f $CONFIG ]]; then | ||
$EXECUTABLE $EXECUTABLE_COMMAND $CONFIG_FILE_PARAMETER=$CONFIG ${FILES}; | ||
else | ||
$EXECUTABLE $EXECUTABLE_COMMAND ${FILES}; | ||
fi | ||
git add ${FILES} | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# Validate composer.json before commit | ||
|
||
ESC_SEQ="\x1b[" | ||
COL_RESET=$ESC_SEQ"39;49;00m" | ||
COL_RED=$ESC_SEQ"0;31m" | ||
COL_GREEN=$ESC_SEQ"0;32m" | ||
COL_YELLOW=$ESC_SEQ"0;33m" | ||
|
||
echo | ||
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"composer-validate\"" | ||
|
||
VALID=$(composer validate --strict --no-check-publish --no-check-all | grep "is valid") | ||
|
||
if [ "$VALID" != "" ]; then | ||
echo "Okay" | ||
exit 0 | ||
else | ||
printf "$COL_RED%s$COL_RESET\r\n" "Composer validate check failed." | ||
exit 1 | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# Run composer phpstan | ||
|
||
ESC_SEQ="\x1b[" | ||
COL_RESET=$ESC_SEQ"39;49;00m" | ||
COL_RED=$ESC_SEQ"0;31m" | ||
COL_GREEN=$ESC_SEQ"0;32m" | ||
COL_YELLOW=$ESC_SEQ"0;33m" | ||
|
||
echo | ||
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"phpstan\"" | ||
|
||
if composer phpstan; then | ||
echo "Okay" | ||
exit 0 | ||
else | ||
printf "$COL_RED%s$COL_RESET\r\n" "phpstan analysis failed." | ||
exit 1 | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# Run composer test | ||
|
||
ESC_SEQ="\x1b[" | ||
COL_RESET=$ESC_SEQ"39;49;00m" | ||
COL_RED=$ESC_SEQ"0;31m" | ||
COL_GREEN=$ESC_SEQ"0;32m" | ||
COL_YELLOW=$ESC_SEQ"0;33m" | ||
|
||
echo | ||
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"test-code\"" | ||
|
||
if composer test; then | ||
echo "Okay" | ||
exit 0 | ||
else | ||
printf "$COL_RED%s$COL_RESET\r\n" "Tests failed." | ||
exit 1 | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# Validate composer.json before commit | ||
|
||
ESC_SEQ="\x1b[" | ||
COL_RESET=$ESC_SEQ"39;49;00m" | ||
COL_RED=$ESC_SEQ"0;31m" | ||
COL_GREEN=$ESC_SEQ"0;32m" | ||
COL_YELLOW=$ESC_SEQ"0;33m" | ||
|
||
echo | ||
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"composer-validate\"" | ||
|
||
VALID=$(composer validate --strict --no-check-publish --no-check-all | grep "is valid") | ||
|
||
if [ "$VALID" != "" ]; then | ||
echo "Okay" | ||
exit 0 | ||
else | ||
printf "$COL_RED%s$COL_RESET\r\n" "Composer validate check failed." | ||
exit 1 | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# - 'composer update' if changed composer.json | ||
|
||
ESC_SEQ="\x1b[" | ||
COL_RESET=$ESC_SEQ"39;49;00m" | ||
COL_RED=$ESC_SEQ"0;31m" | ||
COL_GREEN=$ESC_SEQ"0;32m" | ||
COL_YELLOW=$ESC_SEQ"0;33m" | ||
|
||
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)" | ||
|
||
check_run() { | ||
echo "$changed_files" | grep -q "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2" | ||
} | ||
|
||
check_run composer.json "composer update" | ||
exit 0 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
# Lint all added php-files via 'php -l' | ||
|
||
ROOT_DIR="$(pwd)/" | ||
LIST=$(git diff-index --cached --name-only --diff-filter=ACMR HEAD) | ||
ERRORS_BUFFER="" | ||
ESC_SEQ="\x1b[" | ||
COL_RESET=$ESC_SEQ"39;49;00m" | ||
COL_RED=$ESC_SEQ"0;31m" | ||
COL_GREEN=$ESC_SEQ"0;32m" | ||
COL_YELLOW=$ESC_SEQ"0;33m" | ||
COL_BLUE=$ESC_SEQ"0;34m" | ||
COL_MAGENTA=$ESC_SEQ"0;35m" | ||
COL_CYAN=$ESC_SEQ"0;36m" | ||
|
||
echo | ||
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-commit hook: \"php-linter\"" | ||
|
||
for file in $LIST | ||
do | ||
EXTENSION=$(echo "$file" | grep -E ".php$|.module$|.inc$|.install$") | ||
if [ "$EXTENSION" != "" ]; then | ||
ERRORS=$(php -l $ROOT_DIR$file 2>&1 | grep "Parse error") | ||
if [ "$ERRORS" != "" ]; then | ||
if [ "$ERRORS_BUFFER" != "" ]; then | ||
ERRORS_BUFFER="$ERRORS_BUFFER\n$ERRORS" | ||
else | ||
ERRORS_BUFFER="$ERRORS" | ||
fi | ||
echo "Syntax errors found in file: $file " | ||
fi | ||
fi | ||
done | ||
if [ "$ERRORS_BUFFER" != "" ]; then | ||
echo | ||
echo "These errors were found in try-to-commit files: " | ||
echo -e $ERRORS_BUFFER | ||
echo | ||
printf "$COL_RED%s$COL_RESET\r\n\r\n" "Can't commit, fix errors first." | ||
exit 1 | ||
else | ||
echo "Okay" | ||
exit 0 | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
|
||
# Check code style via '.php-cs-fixer.php' | ||
|
||
EXECUTABLE_NAME=php-cs-fixer | ||
EXECUTABLE_COMMAND=fix | ||
CONFIG_FILE=.php-cs-fixer.php | ||
CONFIG_FILE_PARAMETER='--config' | ||
ROOT=`pwd` | ||
ESC_SEQ="\x1b[" | ||
COL_RESET=$ESC_SEQ"39;49;00m" | ||
COL_RED=$ESC_SEQ"0;31m" | ||
COL_GREEN=$ESC_SEQ"0;32m" | ||
COL_YELLOW=$ESC_SEQ"0;33m" | ||
COL_BLUE=$ESC_SEQ"0;34m" | ||
COL_MAGENTA=$ESC_SEQ"0;35m" | ||
COL_CYAN=$ESC_SEQ"0;36m" | ||
|
||
echo "" | ||
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-commit hook: \"php-cs-fixer\"" | ||
|
||
# possible locations | ||
locations=( | ||
$ROOT/bin/$EXECUTABLE_NAME | ||
$ROOT/vendor/bin/$EXECUTABLE_NAME | ||
) | ||
|
||
for location in ${locations[*]} | ||
do | ||
if [[ -x $location ]]; then | ||
EXECUTABLE=$location | ||
break | ||
fi | ||
done | ||
|
||
if [[ ! -x $EXECUTABLE ]]; then | ||
echo "executable $EXECUTABLE_NAME not found, exiting..." | ||
echo "if you're sure this is incorrect, make sure they're executable (chmod +x)" | ||
exit | ||
fi | ||
|
||
echo "using \"$EXECUTABLE_NAME\" located at $EXECUTABLE" | ||
$EXECUTABLE --version | ||
|
||
if [[ -f $ROOT/$CONFIG_FILE ]]; then | ||
CONFIG=$ROOT/$CONFIG_FILE | ||
echo "config file located at $CONFIG loaded" | ||
fi | ||
|
||
FILES=`git status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | sed -e "s/_ide_helper.php$//" | sed -e "s/_ide_helper_models.php$//" | sed -e "s/.phpstorm.meta.php$//" | tr '\n' ' ' | sed 's/ *$//g'` | ||
if [ -z "$FILES" ]; then | ||
echo "No php files found to fix." | ||
else | ||
echo "Fixing files ${FILES} in project"; | ||
if [[ -f $CONFIG ]]; then | ||
$EXECUTABLE $EXECUTABLE_COMMAND $CONFIG_FILE_PARAMETER=$CONFIG ${FILES}; | ||
else | ||
$EXECUTABLE $EXECUTABLE_COMMAND ${FILES}; | ||
fi | ||
git add ${FILES} | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# Run composer phpstan | ||
|
||
ESC_SEQ="\x1b[" | ||
COL_RESET=$ESC_SEQ"39;49;00m" | ||
COL_RED=$ESC_SEQ"0;31m" | ||
COL_GREEN=$ESC_SEQ"0;32m" | ||
COL_YELLOW=$ESC_SEQ"0;33m" | ||
|
||
echo | ||
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"phpstan\"" | ||
|
||
if composer phpstan; then | ||
echo "Okay" | ||
exit 0 | ||
else | ||
printf "$COL_RED%s$COL_RESET\r\n" "phpstan analysis failed." | ||
exit 1 | ||
fi |
Oops, something went wrong.