#!/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 diff -r -p -m -M --full-index --staged | cat)

# Run GrumPHP
vagrant ssh --command '$(which sh)' << COMMANDS

  # Transfer the DIFF
  DIFF=\$(cat <<- '__GRUMPHP_DIFF_HEREDOC__'
	${DIFF}
	__GRUMPHP_DIFF_HEREDOC__
  )

  printf "%s\n" "\${DIFF}" | exec $(HOOK_COMMAND) '--ansi' '--skip-success-output'
COMMANDS
