Permalink
Browse files

Let the configuration file specify verbosity

  • Loading branch information...
Benjamin VanEvery
Benjamin VanEvery committed Jan 30, 2012
1 parent 0966ad3 commit ba2194037c4597c7df5da2c7ff256152d907cb35
Showing with 19 additions and 7 deletions.
  1. +6 −0 README.md
  2. +4 −4 hooks/pre-receive
  3. +3 −1 hooks/pre-receive.php
  4. +4 −1 lib/Git_Hook/Pre_Receive.php
  5. +2 −1 test/lib/Git_Hook/Pre_Receive_Test.php
View
@@ -66,6 +66,9 @@ This hook checks the health of a jenkins job. See below for example configuratio
; Otherwise, use this config to override
job_name = 'the-build'
+ ; Show progress as hook runs
+ verbose = yes
+
enabled = yes
@@ -84,6 +87,9 @@ for example configuration.
host = gerrit.internal-ip.company.com
port = 29418
+ ; Show progress as hook runs
+ verbose = yes
+
enabled = yes
View
@@ -17,7 +17,7 @@ declare BART_HOOKS="$(dirname $(readlink $0))"
# The main 'while' loop goes over each branch.
# The inner 'for' loop goes ever each commit on that branch
while true; do
- read oldhead newhead branch
+ read oldhead newhead branch || exit 0
# Check if we're done looping thru every branch
if [ -z "$oldhead" -a -z "$newhead" -a -z "$branch" ]; then
@@ -26,8 +26,8 @@ while true; do
# Check if we have everything as expected
if [ -z "$oldhead" -o -z "$newhead" -o -z "$branch" ]; then
- echo "Unexpected: One of the required parameters is empty"
- echo "oldhead: $oldhead, newhead: $newhead, branch: $branch"
+ echo >&2 "Unexpected: One of the required parameters is empty"
+ echo >&2 "oldhead: $oldhead, newhead: $newhead, branch: $branch"
exit 1
fi
@@ -46,7 +46,7 @@ while true; do
--repo $REPO \
"$commit_hash"
- if [ $? -ne 0 ]; then
+ if [[ $? -ne 0 ]]; then
echo >&2 "
Hooks failed."
exit 1
View
@@ -52,6 +52,7 @@ function show_usage($exit_status)
{
$hook = new Git_Hook_Pre_Receive($git_dir, $repo, $witness);
$hook->verify_all($hash);
+ $witness->report('All hooks passed');
}
catch(Exception $e)
{
@@ -71,4 +72,5 @@ function verify_param($name)
echo2(Escape_Colors::fg_color('red', 'Incorrect parameters: missing ' . $name));
show_usage(1);
-}
+}
+
@@ -68,6 +68,9 @@ private function create_hook_for($hook_name)
if (!$conf['enabled']) return null;
- return new $class($conf, $this->git_dir, $this->repo, $this->w, $this->di);
+ $w = ($conf['verbose']) ? new Witness() : $this->w;
+ $w->report('...pre-receive verifying ' . $hook_name);
+
+ return new $class($conf, $this->git_dir, $this->repo, $w, $this->di);
}
}
@@ -67,6 +67,7 @@ public function test_verify_fails()
'pre_receive' => array('names' => 'jenkins'),
'jenkins' => array(
'class' => 'For_Testing',
+ 'verbose' => false,
'enabled' => true,
'super' => 'duper',
),
@@ -134,4 +135,4 @@ public function verify($commit_hash)
$phpu->assertEquals('.git', $this->dir, 'Wrong git dir passed');
$phpu->assertEquals('duper', $this->conf['super'], 'Wrong conf passed');
}
-}
+}

0 comments on commit ba21940

Please sign in to comment.