diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2009-11-07 10:40:22 +0100 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2009-11-07 10:40:22 +0100 |
commit | c3e2186b15901579cec17aca22646b9dddf2363f (patch) | |
tree | fe564afc032a7870fafb885e34f9682154039c5d /tools/git-notify | |
parent | 71351c5a4db3a143ca23d7614c23e80b31bdd15c (diff) | |
download | monitoring-plugins-c3e2186b15901579cec17aca22646b9dddf2363f.tar.gz |
git-notify: Support SourceForge repositories
The Gitweb URLs for repositories hosted by SourceForge are slightly
different than other Gitweb URLs. The correct URL cannot be specified
via "-u" if we append "/$repos_name.git/?" to that URL as we usually do.
If the new "-S" flag is specified or "notify.sourceforge" is set, we'll
append "/$repos_name;" instead, which makes the "-u" option usable for
SourceForge repositories.
Diffstat (limited to 'tools/git-notify')
-rwxr-xr-x | tools/git-notify | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/tools/git-notify b/tools/git-notify index b3223a87..faa17850 100755 --- a/tools/git-notify +++ b/tools/git-notify | |||
@@ -22,6 +22,7 @@ | |||
22 | # -m addr Send mail notifications to specified address | 22 | # -m addr Send mail notifications to specified address |
23 | # -n max Set max number of individual mails to send | 23 | # -n max Set max number of individual mails to send |
24 | # -r name Set the git repository name | 24 | # -r name Set the git repository name |
25 | # -S Enable compatibility with SourceForge's gitweb URLs | ||
25 | # -s bytes Set the maximum diff size in bytes (-1 for no limit) | 26 | # -s bytes Set the maximum diff size in bytes (-1 for no limit) |
26 | # -T Prefix the mail subject with a [repository name] tag | 27 | # -T Prefix the mail subject with a [repository name] tag |
27 | # -t file Prevent duplicate notifications by saving state to this file | 28 | # -t file Prevent duplicate notifications by saving state to this file |
@@ -72,6 +73,9 @@ my $gitweb_url = git_config( "notify.baseurl" ); | |||
72 | # abbreviate the SHA1 name within gitweb URLs (can be set with the -z option) | 73 | # abbreviate the SHA1 name within gitweb URLs (can be set with the -z option) |
73 | my $abbreviate_url = git_config( "notify.shorturls" ); | 74 | my $abbreviate_url = git_config( "notify.shorturls" ); |
74 | 75 | ||
76 | # enable compatibility with SourceForge's gitweb (can be set with the -S option) | ||
77 | my $sourceforge = git_config( "notify.sourceforge" ); | ||
78 | |||
75 | # default repository name (can be changed with the -r option) | 79 | # default repository name (can be changed with the -r option) |
76 | my $repos_name = git_config( "notify.repository" ) || get_repos_name(); | 80 | my $repos_name = git_config( "notify.repository" ) || get_repos_name(); |
77 | 81 | ||
@@ -112,6 +116,7 @@ sub usage() | |||
112 | print " -m addr Send mail notifications to specified address\n"; | 116 | print " -m addr Send mail notifications to specified address\n"; |
113 | print " -n max Set max number of individual mails to send\n"; | 117 | print " -n max Set max number of individual mails to send\n"; |
114 | print " -r name Set the git repository name\n"; | 118 | print " -r name Set the git repository name\n"; |
119 | print " -S Enable compatibility with SourceForge's gitweb URLs\n"; | ||
115 | print " -s bytes Set the maximum diff size in bytes (-1 for no limit)\n"; | 120 | print " -s bytes Set the maximum diff size in bytes (-1 for no limit)\n"; |
116 | print " -T Prefix the mail subject with a [repository name] tag\n"; | 121 | print " -T Prefix the mail subject with a [repository name] tag\n"; |
117 | print " -t file Prevent duplicate notifications by saving state to this file\n"; | 122 | print " -t file Prevent duplicate notifications by saving state to this file\n"; |
@@ -300,6 +305,7 @@ sub parse_options() | |||
300 | elsif ($arg eq '-m') { $commitlist_address = shift @ARGV; } | 305 | elsif ($arg eq '-m') { $commitlist_address = shift @ARGV; } |
301 | elsif ($arg eq '-n') { $max_individual_notices = shift @ARGV; } | 306 | elsif ($arg eq '-n') { $max_individual_notices = shift @ARGV; } |
302 | elsif ($arg eq '-r') { $repos_name = shift @ARGV; } | 307 | elsif ($arg eq '-r') { $repos_name = shift @ARGV; } |
308 | elsif ($arg eq '-S') { $sourceforge = 1; } | ||
303 | elsif ($arg eq '-s') { $max_diff_size = shift @ARGV; } | 309 | elsif ($arg eq '-s') { $max_diff_size = shift @ARGV; } |
304 | elsif ($arg eq '-T') { $emit_repo = 1; } | 310 | elsif ($arg eq '-T') { $emit_repo = 1; } |
305 | elsif ($arg eq '-t') { $state_file = shift @ARGV; } | 311 | elsif ($arg eq '-t') { $state_file = shift @ARGV; } |
@@ -435,7 +441,7 @@ sub send_ref_notice($$@) | |||
435 | ($reftype eq "tag" ? "Tag:" : "Branch:") . $refname, | 441 | ($reftype eq "tag" ? "Tag:" : "Branch:") . $refname, |
436 | @notice, | 442 | @notice, |
437 | ($action ne "removed" and $gitweb_url) | 443 | ($action ne "removed" and $gitweb_url) |
438 | ? "URL: $gitweb_url/?a=shortlog;h=$ref" : undef), | 444 | ? "URL: ${gitweb_url}a=shortlog;h=$ref" : undef), |
439 | "", | 445 | "", |
440 | "The $refname $reftype has been $action."); | 446 | "The $refname $reftype has been $action."); |
441 | 447 | ||
@@ -461,7 +467,7 @@ sub send_commit_notice($$) | |||
461 | close REVPARSE or die $! ? "Cannot execute rev-parse: $!" : "rev-parse exited with status: $?"; | 467 | close REVPARSE or die $! ? "Cannot execute rev-parse: $!" : "rev-parse exited with status: $?"; |
462 | } | 468 | } |
463 | $obj_string = $obj if not defined $obj_string; | 469 | $obj_string = $obj if not defined $obj_string; |
464 | $url = "$gitweb_url/?a=$info{type};h=$obj_string"; | 470 | $url = "${gitweb_url}a=$info{type};h=$obj_string"; |
465 | } | 471 | } |
466 | 472 | ||
467 | if ($info{"type"} eq "tag") | 473 | if ($info{"type"} eq "tag") |
@@ -509,7 +515,7 @@ sub send_commit_notice($$) | |||
509 | } | 515 | } |
510 | else | 516 | else |
511 | { | 517 | { |
512 | push @notice, "Diff: $gitweb_url/?a=commitdiff;h=$obj_string" if $gitweb_url; | 518 | push @notice, "Diff: ${gitweb_url}a=commitdiff;h=$obj_string" if $gitweb_url; |
513 | } | 519 | } |
514 | $subject = $info{"author_name"} . ": " unless $omit_author; | 520 | $subject = $info{"author_name"} . ": " unless $omit_author; |
515 | } | 521 | } |
@@ -566,7 +572,7 @@ sub send_cia_notice($$) | |||
566 | 572 | ||
567 | push @cia_text, | 573 | push @cia_text, |
568 | " </files>", | 574 | " </files>", |
569 | $gitweb_url ? " <url>" . xml_escape("$gitweb_url/?a=commit;h=$commit") . "</url>" : "", | 575 | $gitweb_url ? " <url>" . xml_escape("${gitweb_url}a=commit;h=$commit") . "</url>" : "", |
570 | " </commit>", | 576 | " </commit>", |
571 | " </body>", | 577 | " </body>", |
572 | " <timestamp>" . $info{"author_date"} . "</timestamp>", | 578 | " <timestamp>" . $info{"author_date"} . "</timestamp>", |
@@ -583,7 +589,7 @@ sub send_global_notice($$$) | |||
583 | 589 | ||
584 | foreach my $rev (@$notice) | 590 | foreach my $rev (@$notice) |
585 | { | 591 | { |
586 | $rev =~ s/^commit /URL: $gitweb_url\/?a=commit;h=/ if $gitweb_url; | 592 | $rev =~ s/^commit /URL: ${gitweb_url}a=commit;h=/ if $gitweb_url; |
587 | } | 593 | } |
588 | 594 | ||
589 | mail_notification($commitlist_address, "New commits on branch $ref", "text/plain; charset=UTF-8", @$notice); | 595 | mail_notification($commitlist_address, "New commits on branch $ref", "text/plain; charset=UTF-8", @$notice); |
@@ -662,7 +668,9 @@ parse_options(); | |||
662 | umask( $mode_mask ); | 668 | umask( $mode_mask ); |
663 | 669 | ||
664 | # append repository path to URL | 670 | # append repository path to URL |
665 | $gitweb_url .= "/$repos_name.git" if $gitweb_url; | 671 | if ($gitweb_url) { |
672 | $gitweb_url .= $sourceforge ? "/$repos_name;" : "/$repos_name.git/?"; | ||
673 | } | ||
666 | 674 | ||
667 | if (@ARGV) | 675 | if (@ARGV) |
668 | { | 676 | { |