Skip to content

Update commit-msg #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions config/grumphp/hooks/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,12 @@ DOCKER_PHP_CONTAINER_ID=$(docker-compose -f ${DOCKER_COMPOSE_FILE} ps -q phpfpm)
# Remove single quotes from hook_command. It is needed to use it inside the docker exec
HOOK_COMMAND=$(echo "$(HOOK_COMMAND)" | sed "s/'//g")

printf "%s\n" "${DIFF}" > "${DIFF_FILE}" && docker cp "${DIFF_FILE}" ${DOCKER_PHP_CONTAINER_ID}:"/tmp/${DIFF_FILE}"

# Run GrumPHP
docker exec -t \
-e HOOK_EXEC_PATH=${HOOK_EXEC_PATH} -e HOOK_COMMAND="${HOOK_COMMAND}" \
-e GIT_USER="${GIT_USER}" -e GIT_EMAIL="${GIT_EMAIL}" -e COMMIT_MSG_FILE="${COMMIT_MSG_FILE}" \
-e DIFF_FILE="${DIFF_FILE}" \
${DOCKER_PHP_CONTAINER_ID} sh -c \
'cd "${HOOK_EXEC_PATH}" && cat "/tmp/${DIFF_FILE}" | ${HOOK_COMMAND} --git-user="${GIT_USER}" --git-email="${GIT_EMAIL}" "${COMMIT_MSG_FILE}"'
GRUMPHP_EXIT_CODE=$?
(cd "./" && echo "${DIFF}" | \
exec 'docker' 'run' '--rm' '-t' "--volume=$PWD:${HOOK_EXEC_PATH}" "${DOCKER_PHP_CONTAINER_ID}" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ryantfowler this one is also failing for the same reason as #44:

docker: Error: No such image: 62a2c063b218ae30c8f8656487771e158671b5d5390791ac578341649d9eb662.
See 'docker run --help'.

I think that docker run expects an image identifier instead of a container id: "${DOCKER_PHP_CONTAINER_ID}"

'vendor/bin/grumphp' 'git:commit-msg' "--git-user=$GIT_USER" "--git-email=$GIT_EMAIL" "$COMMIT_MSG_FILE" \
'--skip-success-output')

rm -f "${DIFF_FILE}" && docker exec -t \
-u root -e DIFF_FILE="${DIFF_FILE}" \
${DOCKER_PHP_CONTAINER_ID} sh -c 'rm -f "/tmp/${DIFF_FILE}"'
GRUMPHP_EXIT_CODE=$?

exit $GRUMPHP_EXIT_CODE
exit $GRUMPHP_EXIT_CODE