hooks-config: Subsume hooks-chain functionality

Remove hooks-chain.bash and place its content in hooks-config.bash.
This commit is contained in:
Brad King 2013-04-04 13:12:19 -04:00
parent 646b891d70
commit 2d9ee2a97c
5 changed files with 16 additions and 36 deletions

@ -145,5 +145,4 @@ esac
#-----------------------------------------------------------------------------
# Chain to project-specific hook.
. "$HOOKS_DIR/hooks-chain.bash"
hooks_chain commit-msg "$@"

@ -1,33 +0,0 @@
#=============================================================================
# Copyright 2010-2011 Kitware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
hooks_chain() {
hook="$1" ; shift
chain=$(git config --get hooks.chain-$hook) ||
eval chain="\${hooks_chain_${hook//-/_}}"
test -n "$chain" || return 0
case "$chain" in
'/'*) prefix="" ;;
'[A-Za-z]:/'*) prefix="" ;;
'.'*) prefix="" ;;
*) prefix="./" ;;
esac
if test -x "$prefix$chain" ; then
exec "$prefix$chain" "$@"
fi
}
# vim: set filetype=sh tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab :

@ -25,4 +25,20 @@ config=".hooks-config.bash" && test -r "$config" && . "$config"
# Set up the location for "this" set of hooks.
HOOKS_DIR="${BASH_SOURCE%/*}"
hooks_chain() {
hook="$1" ; shift
chain=$(git config --get hooks.chain-$hook) ||
eval chain="\${hooks_chain_${hook//-/_}}"
test -n "$chain" || return 0
case "$chain" in
'/'*) prefix="" ;;
'[A-Za-z]:/'*) prefix="" ;;
'.'*) prefix="" ;;
*) prefix="./" ;;
esac
if test -x "$prefix$chain" ; then
exec "$prefix$chain" "$@"
fi
}
# vim: set filetype=sh tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab :

@ -322,7 +322,6 @@ test -z "$bad" || die "$bad"
#-----------------------------------------------------------------------------
# Chain to project-specific hook.
. "$HOOKS_DIR/hooks-chain.bash"
hooks_chain pre-commit "$@"
# vim: set filetype=sh tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab :

@ -27,5 +27,4 @@ esac
#-----------------------------------------------------------------------------
# Chain to project-specific hook.
. "$HOOKS_DIR/hooks-chain.bash"
hooks_chain prepare-commit-msg "$@"