[Nagiosplug-checkins] SF.net SVN: nagiosplug:[2261] nagiosplug/trunk/tools/git-notify

dermoth at users.sourceforge.net dermoth at users.sourceforge.net
Sat Oct 24 22:59:33 CEST 2009


Revision: 2261
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2261&view=rev
Author:   dermoth
Date:     2009-10-24 20:59:31 +0000 (Sat, 24 Oct 2009)

Log Message:
-----------
git-notify: Remove unused tag notification code

The code which handles notifications regarding tags was unused, as only
objects listed by git-rev-list(1) are considered, and git-rev-list(1)
never spits out the sha1 of a tag object.

From: Holger Weiss <holger at zedat.fu-berlin.de>

Modified Paths:
--------------
    nagiosplug/trunk/tools/git-notify

Modified: nagiosplug/trunk/tools/git-notify
===================================================================
--- nagiosplug/trunk/tools/git-notify	2009-10-24 20:59:10 UTC (rev 2260)
+++ nagiosplug/trunk/tools/git-notify	2009-10-24 20:59:31 UTC (rev 2261)
@@ -194,7 +194,7 @@
     return $repos;
 }
 
-# extract the information from a commit or tag object and return a hash containing the various fields
+# extract the information from a commit object and return a hash containing the various fields
 sub get_object_info($)
 {
     my $obj = shift;
@@ -202,37 +202,23 @@
     my @log = ();
     my $do_log = 0;
 
-    open TYPE, "-|" or exec "git", "cat-file", "-t", $obj or die "cannot run git-cat-file";
-    my $type = <TYPE>;
-    chomp $type;
-    close TYPE;
-
-    open OBJ, "-|" or exec "git", "cat-file", $type, $obj or die "cannot run git-cat-file";
+    open OBJ, "-|" or exec "git", "cat-file", "commit", $obj or die "cannot run git-cat-file";
     while (<OBJ>)
     {
         chomp;
-        if ($do_log)
+        if ($do_log) { push @log, $_; }
+        elsif (/^$/) { $do_log = 1; }
+        elsif (/^(author|committer) ((.*) (<.*>)) (\d+) ([+-]\d+)$/)
         {
-            last if /^-----BEGIN PGP SIGNATURE-----/;
-            push @log, $_;
-        }
-        elsif (/^(author|committer|tagger) ((.*) (<.*>)) (\d+) ([+-]\d+)$/)
-        {
             $info{$1} = $2;
             $info{$1 . "_name"} = $3;
             $info{$1 . "_email"} = $4;
             $info{$1 . "_date"} = $5;
             $info{$1 . "_tz"} = $6;
         }
-        elsif (/^tag (.*)$/)
-        {
-            $info{"tag"} = $1;
-        }
-        elsif (/^$/) { $do_log = 1; }
     }
     close OBJ;
 
-    $info{"type"} = $type;
     $info{"log"} = \@log;
     return %info;
 }
@@ -243,26 +229,10 @@
     my ($ref,$obj) = @_;
     my %info = get_object_info($obj);
     my @notice = ();
-    my $subject;
 
-    if ($info{"type"} eq "tag")
-    {
-        push @notice,
+    push @notice,
         "Module: $repos_name",
         "Branch: $ref",
-        "Tag:    $obj",
-        $gitweb_url ? "URL:    $gitweb_url/?a=tag;h=$obj\n" : "",
-        "Tagger: " . $info{"tagger"},
-        "Date:   " . format_date($info{"tagger_date"},$info{"tagger_tz"}),
-        "",
-        join "\n", @{$info{"log"}};
-        $subject = "Tag " . $info{"tag"} . " : " . $info{"tagger_name"} . ": " . ${$info{"log"}}[0];
-    }
-    else
-    {
-        push @notice,
-        "Module: $repos_name",
-        "Branch: $ref",
         "Commit: $obj",
         $gitweb_url ? "URL:    $gitweb_url/?a=commit;h=$obj\n" : "",
         "Author: " . $info{"author"},
@@ -273,27 +243,26 @@
         "---",
         "";
 
-        open STAT, "-|" or exec "git", "diff-tree", "--stat", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
-        push @notice, join("", <STAT>);
-        close STAT;
+    open STAT, "-|" or exec "git", "diff-tree", "--stat", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
+    push @notice, join("", <STAT>);
+    close STAT;
 
-        open DIFF, "-|" or exec "git", "diff-tree", "-p", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
-        my $diff = join( "", <DIFF> );
-        close DIFF;
+    open DIFF, "-|" or exec "git", "diff-tree", "-p", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
+    my $diff = join( "", <DIFF> );
+    close DIFF;
 
-        if (($max_diff_size == -1) || (length($diff) < $max_diff_size))
-        {
-            push @notice, $diff;
-        }
-        else
-        {
-            push @notice, "Diff:   $gitweb_url/?a=commitdiff;h=$obj" if $gitweb_url;
-        }
-
-        $subject = $info{"author_name"} . ": " . ${$info{"log"}}[0];
+    if (($max_diff_size == -1) || (length($diff) < $max_diff_size))
+    {
+        push @notice, $diff;
     }
+    else
+    {
+        push @notice, "Diff:   $gitweb_url/?a=commitdiff;h=$obj" if $gitweb_url;
+    }
 
-    mail_notification($commitlist_address, $subject, "text/plain; charset=UTF-8", @notice);
+    mail_notification($commitlist_address,
+        $info{"author_name"} . ": " . ${$info{"log"}}[0],
+        "text/plain; charset=UTF-8", @notice);
 }
 
 # send a commit notice to the CIA server
@@ -303,8 +272,6 @@
     my %info = get_object_info($commit);
     my @cia_text = ();
 
-    return if $info{"type"} ne "commit";
-
     push @cia_text,
         "<message>",
         "  <generator>",


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list