[nagiosplug] git-notify: Optionally omit the author name

Holger Weiss hweiss at users.sourceforge.net
Sat Nov 7 10:42:03 CET 2009


 Module: nagiosplug
 Branch: master
 Commit: 366d102dbaa1d8c8569ba0a01a61ca1e8ce201db
 Author: Holger Weiss <holger at zedat.fu-berlin.de>
   Date: Sat Nov  7 02:23:32 2009 +0100
    URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=366d102

git-notify: Optionally omit the author name

If the new "-A" option is specified (or "notify.omitAuthor" is set), the
author name will be omitted from the subject of e-mail notifications.

---

 tools/git-notify |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/tools/git-notify b/tools/git-notify
index 289a5f6..e5094b4 100755
--- a/tools/git-notify
+++ b/tools/git-notify
@@ -15,6 +15,7 @@
 #
 # Usage: git-notify [options] [--] old-sha1 new-sha1 refname
 #
+#   -A        Omit the author name from the mail subject
 #   -C        Show committer in the body if different from the author
 #   -c name   Send CIA notifications under specified project name
 #   -m addr   Send mail notifications to specified address
@@ -51,6 +52,9 @@ my $debug = 0;
 
 # configuration parameters
 
+# omit the author from the mail subject (can be set with the -A option)
+my $omit_author = git_config( "notify.omitauthor" );
+
 # show the committer if different from the author (can be set with the -C option)
 my $show_committer = git_config( "notify.showcommitter" );
 
@@ -93,6 +97,7 @@ my @revlist_options;
 sub usage()
 {
     print "Usage: $0 [options] [--] old-sha1 new-sha1 refname\n";
+    print "   -A        Omit the author name from the mail subject\n";
     print "   -C        Show committer in the body if different from the author\n";
     print "   -c name   Send CIA notifications under specified project name\n";
     print "   -m addr   Send mail notifications to specified address\n";
@@ -275,6 +280,7 @@ sub parse_options()
         my $arg = shift @ARGV;
 
         if ($arg eq '--') { last; }
+        elsif ($arg eq '-A') { $omit_author = 1; }
         elsif ($arg eq '-C') { $show_committer = 1; }
         elsif ($arg eq '-c') { $cia_project_name = shift @ARGV; }
         elsif ($arg eq '-m') { $commitlist_address = shift @ARGV; }
@@ -437,7 +443,8 @@ sub send_commit_notice($$)
           "",
           join "\n", @{$info{"log"}};
 
-        $subject = "Tag " . $info{"tag"} . ": " . $info{"tagger_name"};
+        $subject = "Tag " . $info{"tag"} . ": ";
+        $subject .= $info{"tagger_name"} . ": " unless $omit_author;
     }
     else
     {
@@ -471,10 +478,10 @@ sub send_commit_notice($$)
         {
             push @notice, "Diff: $gitweb_url/?a=commitdiff;h=$obj_string" if $gitweb_url;
         }
-        $subject = $info{"author_name"};
+        $subject = $info{"author_name"} . ": " unless $omit_author;
     }
 
-    $subject .= ": " . truncate_str(${$info{"log"}}[0],50);
+    $subject .= truncate_str(${$info{"log"}}[0],50);
     $_ = decode($info{"encoding"}, $_) for @notice;
     mail_notification($commitlist_address, $subject, "text/plain; charset=UTF-8", @notice);
 }





More information about the Commits mailing list