#!/bin/sh # # Run the post-receive scripts in post-receive.d/ # # 1. After `git push` to a repository, when git finishes updating the refs in # the bare repo, it would run this `post-receive` hook. # 2. When run, the bare repo is the working directory and Git will write one # line per updated ref to stdin e.g. refs/heads/main # 3. *This script* then runs every executable that exists in post-receive.d # sequentially. set -o errexit set -o nounset main() { input=$(cat) for hook in "$(dirname "$0")"/post-receive.d/*; do is_executable "$hook" || continue printf '%s\n' "$input" | "$hook" done } is_executable() { [ -x "$1" ] } main