#!/bin/bash

# This file is managed by Ansible, all changes will be lost

set -e

data=$(cat)
params="${@}"
exitcodes=()
hooktype=$(basename $0)

GIT_DIR="$(git rev-parse --git-dir)"

if [ -e ${GIT_DIR}/hooks/${hooktype}.d ] ; then
  for hook in ${GIT_DIR}/hooks/${hooktype}.d/* ; do
    test -x "${hook}" || continue
    echo "${data}" | "${hook}" "${params}"
    exitcodes+=($?)
  done

  for i in "${exitcodes[@]}"; do
    [ "$i" == 0 ] || exit $i
  done
fi

