From patchwork Tue Apr 27 16:50:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Krafft X-Patchwork-Id: 51096 X-Patchwork-Delegate: jk@ozlabs.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 7BF11B7FB4 for ; Wed, 28 Apr 2010 03:08:40 +1000 (EST) X-Greylist: delayed 345 seconds by postgrey-1.32 at bilbo; Wed, 28 Apr 2010 03:08:38 EST Received: from clegg.madduck.net (clegg.madduck.net [193.242.105.96]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2CE38B7E1F for ; Wed, 28 Apr 2010 03:08:38 +1000 (EST) Received: from lotus.madduck.net (lotus.madduck.net [IPv6:2001:1620:2018:2::4d6d:8b55]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "lotus.madduck.net", Issuer "CAcert Class 3 Root" (verified OK)) by clegg.madduck.net (postfix) with ESMTPS id 257A61D4004; Tue, 27 Apr 2010 19:02:40 +0200 (CEST) Received: by lotus.madduck.net (postfix, from userid 1000) id C05343231E; Tue, 27 Apr 2010 18:51:00 +0200 (CEST) From: "martin f. krafft" To: patchwork@lists.ozlabs.org Subject: [PATCH] Only spout to stderr if $VERBOSE is set Date: Tue, 27 Apr 2010 18:50:56 +0200 Message-Id: <1272387056-31476-1-git-send-email-madduck@madduck.net> X-Mailer: git-send-email 1.6.5 X-Virus-Scanned: clamav-milter 0.95.3 at clegg X-Virus-Status: Clean Cc: "martin f. krafft" X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Informational and warning messages are now inhibited unless $VERBOSE is set. Signed-off-by: martin f. krafft --- lib/git/post-receive.hook | 36 +++++++++++++++++++++++++++++------- 1 files changed, 29 insertions(+), 7 deletions(-) diff --git a/lib/git/post-receive.hook b/lib/git/post-receive.hook index f8a7c18..c7fa5d0 100755 --- a/lib/git/post-receive.hook +++ b/lib/git/post-receive.hook @@ -15,6 +15,28 @@ PWDIR=/srv/patchwork/apps/patchwork do_exit=0 trap "do_exit=1" INT +is_verbose() +{ + [ -n "${VERBOSE:-}" ] +} + +err() +{ + echo "E: $@" >&2 +} + +warn() +{ + is_verbose || return + echo "W: $@" >&2 +} + +msg() +{ + is_verbose || return + echo "I: $@" >&2 +} + get_patchwork_hash() { local hash @@ -42,19 +64,19 @@ update_patches() local cnt; cnt=0 for rev in $(git rev-list --no-merges --reverse ${1}^..${2}); do if [ "$do_exit" = 1 ]; then - echo "I: exiting..." >&2 + msg "exiting..." break fi hash=$(get_patchwork_hash $rev) \ - || { echo "E: failed to hash rev $rev." >&2; continue; } + || { err "failed to hash rev $rev."; continue; } id=$(get_patch_id $hash) \ - || { echo "E: failed to find patch for rev $rev." >&2; continue; } + || { warn "failed to find patch for rev $rev."; continue; } reason="$(set_patch_state $id $3 $rev)" \ - || { echo "E: failed to update patch #$id${reason:+: $reason}." >&2; continue; } - echo "I: set patch #$id to state $3 using rev $rev." >&2 + || { err "failed to update patch #$id${reason:+: $reason}."; continue; } + msg "set patch #$id to state $3 using rev $rev." cnt=$(($cnt + 1)) done - echo "I: $cnt patch(es) updated to state $3." >&2 + msg "$cnt patch(es) updated to state $3." } while read oldrev newrev refname; do @@ -68,6 +90,6 @@ while read oldrev newrev refname; do fi done if [ $found -eq 0 ]; then - echo "E: no mapping for refname $key" >&2 + err "no mapping for refname $key" fi done