Skip to content

Commit bf4ddc7

Browse files
committed
Merge master
2 parents 9b36e81 + 98be5e3 commit bf4ddc7

File tree

18 files changed

+346
-60
lines changed

18 files changed

+346
-60
lines changed

.git_hooks/external_runtime

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
###############################################################################
4+
# External Runtime - вспомогательный скрипт для запуска хуков в отдельной #
5+
# среде, например в контейнере. #
6+
# Использование: #
7+
# 1. Подключите этот файл в скрипт хука: #
8+
# source . $(pwd)/.git_hooks/external_runtime #
9+
# 2. Создайте выше по файловой системе файл .external-runtime, #
10+
# содержащий переменную EXTERNAL_RUNTIME_COMMAND, например: #
11+
# EXTERNAL_RUNTIME_COMMAND="ensi exec-script"
12+
# Этот файл должен отсутствовать в среде запуска.
13+
###############################################################################
14+
15+
EXTERNAL_RUNTIME_FILE=".external-runtime"
16+
17+
ESC_SEQ="\x1b["
18+
COL_RESET=$ESC_SEQ"39;49;00m"
19+
COL_BLUE=$ESC_SEQ"0;34m"
20+
21+
findUp () {
22+
path=$(pwd)
23+
while [[ "$path" != "" && ! -e "$path/$1" ]]; do
24+
path=${path%/*}
25+
done
26+
echo "$path"
27+
}
28+
29+
# search external runtime file
30+
rcpath=$(findUp "$EXTERNAL_RUNTIME_FILE")
31+
if [[ "$rcpath" != "" ]]; then
32+
# source it and run hook in via runtime command
33+
. $rcpath/$EXTERNAL_RUNTIME_FILE
34+
printf "$COL_BLUE%s$COL_RESET\n" "External runtime has been found. Running hook with '$EXTERNAL_RUNTIME_COMMAND' command"
35+
$EXTERNAL_RUNTIME_COMMAND $0
36+
exit $?
37+
fi

.git_hooks/post-checkout/install-dependencies.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
source $(pwd)/.git_hooks/external_runtime
4+
35
ESC_SEQ="\x1b["
46
COL_RESET=$ESC_SEQ"39;49;00m"
57
COL_RED=$ESC_SEQ"0;31m"

.git_hooks/post-merge/install-dependencies.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
source $(pwd)/.git_hooks/external_runtime
4+
35
ESC_SEQ="\x1b["
46
COL_RESET=$ESC_SEQ"39;49;00m"
57
COL_RED=$ESC_SEQ"0;31m"

.git_hooks/pre-commit/lint-php.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
source $(pwd)/.git_hooks/external_runtime
4+
35
ROOT_DIR="$(pwd)/"
46
LIST=$(git diff-index --cached --name-only --diff-filter=ACMR HEAD)
57
ERRORS_BUFFER=""

.git_hooks/pre-commit/php-cs-fixer.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
source $(pwd)/.git_hooks/external_runtime
4+
35
EXECUTABLE_NAME=php-cs-fixer
46
EXECUTABLE_COMMAND=fix
57
CONFIG_FILE=.php-cs-fixer.php

.git_hooks/pre-push/composer-validate.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
source $(pwd)/.git_hooks/external_runtime
4+
35
# validate composer
46

57
ESC_SEQ="\x1b["

.git_hooks/pre-push/test-code.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
source $(pwd)/.git_hooks/external_runtime
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: \"test-code\""
13+
14+
if composer test; then
15+
echo "Okay"
16+
exit 0
17+
else
18+
printf "$COL_RED%s$COL_RESET\r\n" "Tests failed."
19+
exit 1
20+
fi

.git_hooks/pre-push/var-dump-checker.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
source $(pwd)/.git_hooks/external_runtime
4+
35
ESC_SEQ="\x1b["
46
COL_RESET=$ESC_SEQ"39;49;00m"
57
COL_RED=$ESC_SEQ"0;31m"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ build
1212
generated
1313
vendor
1414
node_modules
15+
coverage

.huskyrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"post-checkout": ".git_hooks/post-checkout/install-dependencies.sh",
44
"post-merge": ".git_hooks/post-merge/install-dependencies.sh",
55
"pre-commit": ".git_hooks/pre-commit/lint-php.sh && .git_hooks/pre-commit/php-cs-fixer.sh",
6-
"pre-push": ".git_hooks/pre-push/composer-validate.sh && .git_hooks/pre-push/var-dump-checker.sh && composer test"
6+
"pre-push": ".git_hooks/pre-push/composer-validate.sh && .git_hooks/pre-push/var-dump-checker.sh && .git_hooks/pre-push/test-code.sh"
77
}
88
}

0 commit comments

Comments
 (0)