diff options
-rwxr-xr-x | commit-msg | 5 | ||||
-rw-r--r-- | hooks-chain.bash | 31 | ||||
-rwxr-xr-x | pre-commit | 5 | ||||
-rwxr-xr-x | prepare-commit-msg | 21 |
4 files changed, 62 insertions, 0 deletions
diff --git a/commit-msg b/commit-msg index 92a95cd025..7856f1ef57 100755 --- a/commit-msg +++ b/commit-msg @@ -125,3 +125,8 @@ case "$hooks_GerritId" in '') gerrit_advice ;; *) gerrit_error ;; esac + +#----------------------------------------------------------------------------- +# Chain to project-specific hook. +. "$GIT_DIR/hooks/hooks-chain.bash" +hooks_chain commit-msg "$@" diff --git a/hooks-chain.bash b/hooks-chain.bash new file mode 100644 index 0000000000..63c1f4019b --- /dev/null +++ b/hooks-chain.bash @@ -0,0 +1,31 @@ +#============================================================================= +# Copyright 2010 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) || 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 : diff --git a/pre-commit b/pre-commit index 15a0151b00..0f710552c8 100755 --- a/pre-commit +++ b/pre-commit @@ -252,4 +252,9 @@ test -z "$bad" || die "$bad" # Style hooks. . "$GIT_DIR/hooks/pre-commit-style" +#----------------------------------------------------------------------------- +# Chain to project-specific hook. +. "$GIT_DIR/hooks/hooks-chain.bash" +hooks_chain pre-commit "$@" + # vim: set filetype=sh tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab : diff --git a/prepare-commit-msg b/prepare-commit-msg new file mode 100755 index 0000000000..505b522d52 --- /dev/null +++ b/prepare-commit-msg @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +#============================================================================= +# Copyright 2010 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. +#============================================================================= + +#----------------------------------------------------------------------------- +# Chain to project-specific hook. +. "$GIT_DIR/hooks/hooks-chain.bash" +hooks_chain prepare-commit-msg "$@" |