summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2009-11-07 09:40:22 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2009-11-07 09:40:22 (GMT)
commitecdb5aa53f8e6988c1b013e7fc0725edcac17e2b (patch)
treee59b2585a654b7773b798c3892304cbfe4763fcf /tools
parent73141bfd92b8baec4dfd45bb99275b53512ec2b9 (diff)
downloadmonitoring-plugins-ecdb5aa53f8e6988c1b013e7fc0725edcac17e2b.tar.gz
git-notify: Distinguish between tag types
Distinguish between annotated tags and lightweight tags. In the former case, send an annotated "tag notification", in the latter case, send a "ref change notification" (as we did in both cases before).
Diffstat (limited to 'tools')
-rwxr-xr-xtools/git-notify29
1 files changed, 24 insertions, 5 deletions
diff --git a/tools/git-notify b/tools/git-notify
index e64754c..dc843ef 100755
--- a/tools/git-notify
+++ b/tools/git-notify
@@ -352,6 +352,18 @@ sub get_repos_name()
352 return $repos; 352 return $repos;
353} 353}
354 354
355# return the type of the given object
356sub get_object_type($)
357{
358 my $obj = shift;
359
360 open TYPE, "-|" or exec "git", "cat-file", "-t", $obj or die "cannot run git-cat-file";
361 my $type = <TYPE>;
362 chomp $type;
363 close TYPE or die $! ? "Cannot execute cat-file: $!" : "cat-file exited with status: $?";
364 return $type;
365}
366
355# extract the information from a commit or tag object and return a hash containing the various fields 367# extract the information from a commit or tag object and return a hash containing the various fields
356sub get_object_info($) 368sub get_object_info($)
357{ 369{
@@ -362,10 +374,7 @@ sub get_object_info($)
362 374
363 $info{"encoding"} = "utf-8"; 375 $info{"encoding"} = "utf-8";
364 376
365 open TYPE, "-|" or exec "git", "cat-file", "-t", $obj or die "cannot run git-cat-file"; 377 my $type = get_object_type($obj);
366 my $type = <TYPE>;
367 chomp $type;
368 close TYPE or die $! ? "Cannot execute cat-file: $!" : "cat-file exited with status: $?";
369 378
370 open OBJ, "-|" or exec "git", "cat-file", $type, $obj or die "cannot run git-cat-file"; 379 open OBJ, "-|" or exec "git", "cat-file", $type, $obj or die "cannot run git-cat-file";
371 while (<OBJ>) 380 while (<OBJ>)
@@ -572,13 +581,18 @@ sub send_global_notice($$$)
572sub send_all_notices($$$) 581sub send_all_notices($$$)
573{ 582{
574 my ($old_sha1, $new_sha1, $ref) = @_; 583 my ($old_sha1, $new_sha1, $ref) = @_;
575 my ($reftype, $refname, $action, @notice); 584 my ($reftype, $refname, $tagtype, $action, @notice);
576 585
577 return if ($ref =~ /^refs\/remotes\// 586 return if ($ref =~ /^refs\/remotes\//
578 or (@include_list && !grep {$_ eq $ref} @include_list)); 587 or (@include_list && !grep {$_ eq $ref} @include_list));
579 die "The name \"$ref\" doesn't sound like a local branch or tag" 588 die "The name \"$ref\" doesn't sound like a local branch or tag"
580 if not (($reftype, $refname) = ($ref =~ /^refs\/(head|tag)s\/(.+)/)); 589 if not (($reftype, $refname) = ($ref =~ /^refs\/(head|tag)s\/(.+)/));
581 590
591 if ($reftype eq "tag")
592 {
593 $tagtype = get_object_type($ref) eq "tag" ? "annotated" : "lightweight";
594 }
595
582 if ($new_sha1 eq '0' x 40) 596 if ($new_sha1 eq '0' x 40)
583 { 597 {
584 $action = "removed"; 598 $action = "removed";
@@ -586,6 +600,11 @@ sub send_all_notices($$$)
586 } 600 }
587 elsif ($old_sha1 eq '0' x 40) 601 elsif ($old_sha1 eq '0' x 40)
588 { 602 {
603 if ($reftype eq "tag" and $tagtype eq "annotated")
604 {
605 send_commit_notice( $refname, $new_sha1 ) if $commitlist_address;
606 return;
607 }
589 $action = "created"; 608 $action = "created";
590 @notice = ( "SHA1: $new_sha1" ); 609 @notice = ( "SHA1: $new_sha1" );
591 } 610 }