-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit-msg
More file actions
executable file
·35 lines (25 loc) · 1.11 KB
/
commit-msg
File metadata and controls
executable file
·35 lines (25 loc) · 1.11 KB
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
32
33
34
35
#!/bin/sh
#
# Run the hook command.
# Note: this will be replaced by the real command during copy.
#
GIT_USER=$(git config user.name)
GIT_EMAIL=$(git config user.email)
COMMIT_MSG_FILE=$1
# 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:commit-msg' "--git-user=$GIT_USER" "--git-email=$GIT_EMAIL" "$COMMIT_MSG_FILE"
fi
printf "%s\n" "${DIFF}" | exec 'vendor/bin/grumphp.phar' 'git:commit-msg' "--git-user=$GIT_USER" "--git-email=$GIT_EMAIL" "$COMMIT_MSG_FILE"