Skip to content

Commit c8ec89b

Browse files
committed
[Fix] Grumphp always returns success because does not receive the diff files:
- stdin needs to be passed inside the docker command because docker does not get previous stdin if not running using -i. - We need -t for the message colors but we cannot use -ti because we cannot use TTY here - If using -t but not -i, we need to pass the stdin as variable to be used inside the docker command
1 parent f4d3923 commit c8ec89b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

config/grumphp/hooks/docker/commit-msg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ DOCKER_COMPOSE_FILE=${DOCKER_COMPOSE_DIR}/docker-compose.yml
2222
DOCKER_PHP_CONTAINER_ID=$(docker-compose -f ${DOCKER_COMPOSE_FILE} ps -q phpfpm)
2323

2424
# Run GrumPHP
25-
(cd "${HOOK_EXEC_PATH}" && printf "%s\n" "${DIFF}" | docker exec -t ${DOCKER_PHP_CONTAINER_ID} $(HOOK_COMMAND) "--git-user=$GIT_USER" "--git-email=$GIT_EMAIL" "$COMMIT_MSG_FILE")
25+
DIFF_STDIN=$(cd "${HOOK_EXEC_PATH}" && printf "%s\n" "${DIFF}")
26+
docker exec -t ${DOCKER_PHP_CONTAINER_ID} sh -c "echo '${DIFF_STDIN}' | $(HOOK_COMMAND) '--git-user=${GIT_USER}' '--git-email=${GIT_EMAIL}' '${COMMIT_MSG_FILE}'"

config/grumphp/hooks/docker/pre-commit

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ DOCKER_COMPOSE_FILE=${DOCKER_COMPOSE_DIR}/docker-compose.yml
1818
DOCKER_PHP_CONTAINER_ID=$(docker-compose -f ${DOCKER_COMPOSE_FILE} ps -q phpfpm)
1919

2020
# Run GrumPHP
21-
(cd "${HOOK_EXEC_PATH}" && printf "%s\n" "${DIFF}" | docker exec -t ${DOCKER_PHP_CONTAINER_ID} $(HOOK_COMMAND) '--skip-success-output')
21+
DIFF_STDIN=$(cd "${HOOK_EXEC_PATH}" && printf "%s\n" "${DIFF}")
22+
docker exec -t ${DOCKER_PHP_CONTAINER_ID} sh -c "echo '${DIFF_STDIN}' | $(HOOK_COMMAND) '--skip-success-output'"

0 commit comments

Comments
 (0)