-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·31 lines (22 loc) · 966 Bytes
/
pre-commit
File metadata and controls
executable file
·31 lines (22 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
#
# Run the hook command.
# Note: this will be replaced by the real command during copy.
#
# Fetch the GIT diff and format it as command input:
DIFF=$(git -c diff.mnemonicprefix=false -c diff.noprefix=false --no-pager diff --raw -r -p -m -M --full-index --no-color --staged | cat)
# Grumphp env vars
export GRUMPHP_GIT_WORKING_DIR="$(git rev-parse --show-toplevel)"
cd "${GRUMPHP_GIT_WORKING_DIR}" || exit 1
GRUMPHP_CONFIG_FILE=''
DEVTOOLS_GRUMPHP_CONFIG=__DEV_TOOLS_GRUMPHP_CONFIG__
if [ -f './grumphp.yml' ]; then
GRUMPHP_CONFIG_FILE='./grumphp.yml'
elif [ -f "${DEVTOOLS_GRUMPHP_CONFIG}" ]; then
GRUMPHP_CONFIG_FILE="${DEVTOOLS_GRUMPHP_CONFIG}"
fi
# Run GrumPHP
if [ -n "${GRUMPHP_CONFIG_FILE}" ]; then
printf "%s\n" "${DIFF}" | exec 'vendor/bin/grumphp.phar' '--config' "${GRUMPHP_CONFIG_FILE}" 'git:pre-commit' '--skip-success-output'
fi
printf "%s\n" "${DIFF}" | exec 'vendor/bin/grumphp.phar' 'git:pre-commit' '--skip-success-output'