Commit e6849699 authored by Brad King's avatar Brad King
Browse files

hooks-config: Read 'git config' values from project .hooks-config

Allow projects to configure hooks with a 'git config'-formatted file at
the top of their source tree called ".hooks-config".  This avoids use of
bash-specific syntax and makes configuration declarative.
parent 2d9ee2a9
......@@ -20,6 +20,16 @@ if test -z "$GIT_DIR"; then
# Load hooks configuration from source tree.
if test -r "$hooks_config"; then
hooks_config() {
git config -f "$hooks_config" "$@"
hooks_config() {
config=".hooks-config.bash" && test -r "$config" && . "$config"
# Set up the location for "this" set of hooks.
......@@ -28,6 +38,7 @@ HOOKS_DIR="${BASH_SOURCE%/*}"
hooks_chain() {
hook="$1" ; shift
chain=$(git config --get hooks.chain-$hook) ||
chain="$(hooks_config --get hooks.chain.$hook)" ||
eval chain="\${hooks_chain_${hook//-/_}}"
test -n "$chain" || return 0
case "$chain" in
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment