Commit 0d9698a1 authored by Brad King's avatar Brad King

Load project-specific "start" hooks before our checks

Read from the project ".hooks-config" a configuration value

 hooks.start.commit-msg
 hooks.start.pre-commit
 hooks.start.prepare-commit-msg

to run from our respective hook before its main checks.
parent c530aa93
......@@ -17,6 +17,9 @@
. "${BASH_SOURCE%/*}/hooks-config.bash"
# Start with project-specific hook.
hooks_start commit-msg "$@"
# Prepare a copy of the message:
# - strip comment lines
# - stop at "diff --git" (git commit -v)
......
......@@ -43,6 +43,12 @@ hooks_chain() {
hooks_child "$chain" "$@" || exit
}
hooks_start() {
hook="$1" ; shift
start="$(hooks_config --get hooks.start.$hook)"
hooks_child "$start" "$@" || exit
}
hooks_child() {
child="$1" ; shift
test -n "$child" || return 0
......
......@@ -17,6 +17,9 @@
. "${BASH_SOURCE%/*}/hooks-config.bash"
# Start with project-specific hook.
hooks_start pre-commit "$@"
die() {
echo 'pre-commit hook failure' 1>&2
echo '-----------------------' 1>&2
......
......@@ -17,6 +17,9 @@
. "${BASH_SOURCE%/*}/hooks-config.bash"
# Start with project-specific hook.
hooks_start prepare-commit-msg "$@"
# Invoke the Gerrit Change-Id hook here for "git merge" because
# it does not run the normal commit-msg hook.
hooks_GerritId=$(git config --get hooks.GerritId)
......
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