Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,16 @@ if test -z "$GIT_DIR"; then
fi
# Load hooks configuration from source tree.
hooks_config=".hooks-config"
if test -r "$hooks_config"; then
hooks_config() {
git config -f "$hooks_config" "$@"
}
else
hooks_config() {
false
}
fi
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment