Skip to content

Commit 02aa0e4

Browse files
authored
Merge pull request #12 from ModestCoders/grumphp-improvements
Grumphp improvements
2 parents f45e389 + 4f60e36 commit 02aa0e4

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

config/grumphp/hooks/docker/commit-msg

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ if [[ ${DOCKER_COMPOSE_DIR} = *"/vendor/"* ]]; then
1919
DOCKER_COMPOSE_DIR=${VENDOR_PARENT_DIR}/..
2020
fi
2121
DOCKER_COMPOSE_FILE=${DOCKER_COMPOSE_DIR}/docker-compose.yml
22+
DOCKER_PHP_CONTAINER_ID=$(docker-compose -f ${DOCKER_COMPOSE_FILE} ps -q phpfpm)
23+
24+
# Remove single quotes from hook_command. It is needed to use it inside the docker exec
25+
HOOK_COMMAND=$(echo "$(HOOK_COMMAND)" | sed "s/'//g")
2226

2327
# Run GrumPHP
24-
(cd "${HOOK_EXEC_PATH}" && printf "%s\n" "${DIFF}" | docker-compose --file ${DOCKER_COMPOSE_FILE} exec -T phpfpm $(HOOK_COMMAND) "--git-user=$GIT_USER" "--git-email=$GIT_EMAIL" "$COMMIT_MSG_FILE")
28+
docker exec -t \
29+
-e DIFF="${DIFF}" -e HOOK_EXEC_PATH=${HOOK_EXEC_PATH} -e HOOK_COMMAND="${HOOK_COMMAND}" \
30+
-e GIT_USER="${GIT_USER}" -e GIT_EMAIL="${GIT_EMAIL}" -e COMMIT_MSG_FILE="${COMMIT_MSG_FILE}" \
31+
${DOCKER_PHP_CONTAINER_ID} sh -c \
32+
'cd "${HOOK_EXEC_PATH}" && printf "%s\n" "${DIFF}" | ${HOOK_COMMAND} --git-user="${GIT_USER}" --git-email="${GIT_EMAIL}" "${COMMIT_MSG_FILE}"'

config/grumphp/hooks/docker/pre-commit

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ if [[ ${DOCKER_COMPOSE_DIR} = *"/vendor/"* ]]; then
1515
DOCKER_COMPOSE_DIR=${VENDOR_PARENT_DIR}/..
1616
fi
1717
DOCKER_COMPOSE_FILE=${DOCKER_COMPOSE_DIR}/docker-compose.yml
18+
DOCKER_PHP_CONTAINER_ID=$(docker-compose -f ${DOCKER_COMPOSE_FILE} ps -q phpfpm)
19+
20+
# Remove single quotes from hook_command. It is needed to use it inside the docker exec
21+
HOOK_COMMAND=$(echo "$(HOOK_COMMAND)" | sed "s/'//g")
1822

1923
# Run GrumPHP
20-
(cd "${HOOK_EXEC_PATH}" && printf "%s\n" "${DIFF}" | docker-compose --file ${DOCKER_COMPOSE_FILE} exec -T phpfpm $(HOOK_COMMAND))
24+
docker exec -t \
25+
-e DIFF="${DIFF}" -e HOOK_EXEC_PATH=${HOOK_EXEC_PATH} -e HOOK_COMMAND="${HOOK_COMMAND}" \
26+
${DOCKER_PHP_CONTAINER_ID} sh -c \
27+
'cd "${HOOK_EXEC_PATH}" && printf "%s\n" "${DIFF}" | ${HOOK_COMMAND} --skip-success-output'

0 commit comments

Comments
 (0)