Skip to content

Commit 1386f10

Browse files
authored
Merge pull request #13 from ensi-platform/ensitech-74
ENSITECH-74
2 parents d897372 + 28660b6 commit 1386f10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1802
-7201
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../scripts/install-dependencies.sh
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../scripts/install-dependencies.sh
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../scripts/lint-php.sh
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../scripts/php-cs-fixer.sh
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../scripts/composer-validate.sh

.git_hooks/pre-push/02-phpstan.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../scripts/phpstan.sh
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../scripts/test-code.sh
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Validate composer.json before commit
4+
5+
ESC_SEQ="\x1b["
6+
COL_RESET=$ESC_SEQ"39;49;00m"
7+
COL_RED=$ESC_SEQ"0;31m"
8+
COL_GREEN=$ESC_SEQ"0;32m"
9+
COL_YELLOW=$ESC_SEQ"0;33m"
10+
11+
echo
12+
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"composer-validate\""
13+
14+
VALID=$(composer validate --strict --no-check-publish --no-check-all | grep "is valid")
15+
16+
if [ "$VALID" != "" ]; then
17+
echo "Okay"
18+
exit 0
19+
else
20+
printf "$COL_RED%s$COL_RESET\r\n" "Composer validate check failed."
21+
exit 1
22+
fi
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# - 'composer update' if changed composer.json
4+
5+
ESC_SEQ="\x1b["
6+
COL_RESET=$ESC_SEQ"39;49;00m"
7+
COL_RED=$ESC_SEQ"0;31m"
8+
COL_GREEN=$ESC_SEQ"0;32m"
9+
COL_YELLOW=$ESC_SEQ"0;33m"
10+
11+
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)"
12+
13+
check_run() {
14+
echo "$changed_files" | grep -q "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2"
15+
}
16+
17+
check_run composer.json "composer update"
18+
exit 0

.git_hooks/scripts/lint-php.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
# Lint all added php-files via 'php -l'
4+
5+
ROOT_DIR="$(pwd)/"
6+
LIST=$(git diff-index --cached --name-only --diff-filter=ACMR HEAD | sed '/^templates/d')
7+
ERRORS_BUFFER=""
8+
ESC_SEQ="\x1b["
9+
COL_RESET=$ESC_SEQ"39;49;00m"
10+
COL_RED=$ESC_SEQ"0;31m"
11+
COL_GREEN=$ESC_SEQ"0;32m"
12+
COL_YELLOW=$ESC_SEQ"0;33m"
13+
COL_BLUE=$ESC_SEQ"0;34m"
14+
COL_MAGENTA=$ESC_SEQ"0;35m"
15+
COL_CYAN=$ESC_SEQ"0;36m"
16+
17+
echo
18+
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-commit hook: \"php-linter\""
19+
20+
for file in $LIST
21+
do
22+
EXTENSION=$(echo "$file" | grep -E ".php$|.module$|.inc$|.install$")
23+
if [ "$EXTENSION" != "" ]; then
24+
ERRORS=$(php -l $ROOT_DIR$file 2>&1 | grep "Parse error")
25+
if [ "$ERRORS" != "" ]; then
26+
if [ "$ERRORS_BUFFER" != "" ]; then
27+
ERRORS_BUFFER="$ERRORS_BUFFER\n$ERRORS"
28+
else
29+
ERRORS_BUFFER="$ERRORS"
30+
fi
31+
echo "Syntax errors found in file: $file "
32+
fi
33+
fi
34+
done
35+
if [ "$ERRORS_BUFFER" != "" ]; then
36+
echo
37+
echo "These errors were found in try-to-commit files: "
38+
echo -e $ERRORS_BUFFER
39+
echo
40+
printf "$COL_RED%s$COL_RESET\r\n\r\n" "Can't commit, fix errors first."
41+
exit 1
42+
else
43+
echo "Okay"
44+
exit 0
45+
fi

0 commit comments

Comments
 (0)