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)
commit71351c5a4db3a143ca23d7614c23e80b31bdd15c (patch)
tree6b68e0353946f5a8b81cd276ffc0a9ea5fe1f229 /tools
parent600fecab6a717aa35df2419a6f5205332dae356e (diff)
downloadmonitoring-plugins-71351c5a4db3a143ca23d7614c23e80b31bdd15c.tar.gz
git-notify: Optionally call mail(1) without "-a"
Not all mail(1) implementations support specifying additional header fields via "-a": with some, this flag is used for attaching files, others don't provide an "-a" flag at all (this is true for the /bin/mail utility currently installed on the SourceForge servers, for example). We now provide the "-H" flag and the "notify.legacyMail" configuration key for these cases.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/git-notify14
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/git-notify b/tools/git-notify
index 2970f00..b3223a8 100755
--- a/tools/git-notify
+++ b/tools/git-notify
@@ -18,6 +18,7 @@
18# -A Omit the author name from the mail subject 18# -A Omit the author name from the mail subject
19# -C Show committer in the body if different from the author 19# -C Show committer in the body if different from the author
20# -c name Send CIA notifications under specified project name 20# -c name Send CIA notifications under specified project name
21# -H The mail(1) utility doesn't accept headers via "-a"
21# -m addr Send mail notifications to specified address 22# -m addr Send mail notifications to specified address
22# -n max Set max number of individual mails to send 23# -n max Set max number of individual mails to send
23# -r name Set the git repository name 24# -r name Set the git repository name
@@ -53,6 +54,9 @@ my $debug = 0;
53 54
54# configuration parameters 55# configuration parameters
55 56
57# the $mailer doesn't accept headers via "-a" (can be set with the -H option)
58my $legacy_mail = git_config( "notify.legacymail" );
59
56# omit the author from the mail subject (can be set with the -A option) 60# omit the author from the mail subject (can be set with the -A option)
57my $omit_author = git_config( "notify.omitauthor" ); 61my $omit_author = git_config( "notify.omitauthor" );
58 62
@@ -104,6 +108,7 @@ sub usage()
104 print " -A Omit the author name from the mail subject\n"; 108 print " -A Omit the author name from the mail subject\n";
105 print " -C Show committer in the body if different from the author\n"; 109 print " -C Show committer in the body if different from the author\n";
106 print " -c name Send CIA notifications under specified project name\n"; 110 print " -c name Send CIA notifications under specified project name\n";
111 print " -H The mail(1) utility doesn't accept headers via `-a'\n";
107 print " -m addr Send mail notifications to specified address\n"; 112 print " -m addr Send mail notifications to specified address\n";
108 print " -n max Set max number of individual mails to send\n"; 113 print " -n max Set max number of individual mails to send\n";
109 print " -r name Set the git repository name\n"; 114 print " -r name Set the git repository name\n";
@@ -291,6 +296,7 @@ sub parse_options()
291 elsif ($arg eq '-A') { $omit_author = 1; } 296 elsif ($arg eq '-A') { $omit_author = 1; }
292 elsif ($arg eq '-C') { $show_committer = 1; } 297 elsif ($arg eq '-C') { $show_committer = 1; }
293 elsif ($arg eq '-c') { $cia_project_name = shift @ARGV; } 298 elsif ($arg eq '-c') { $cia_project_name = shift @ARGV; }
299 elsif ($arg eq '-H') { $legacy_mail = 1; }
294 elsif ($arg eq '-m') { $commitlist_address = shift @ARGV; } 300 elsif ($arg eq '-m') { $commitlist_address = shift @ARGV; }
295 elsif ($arg eq '-n') { $max_individual_notices = shift @ARGV; } 301 elsif ($arg eq '-n') { $max_individual_notices = shift @ARGV; }
296 elsif ($arg eq '-r') { $repos_name = shift @ARGV; } 302 elsif ($arg eq '-r') { $repos_name = shift @ARGV; }
@@ -333,7 +339,13 @@ sub mail_notification($$$@)
333 return unless defined $pid; 339 return unless defined $pid;
334 if (!$pid) 340 if (!$pid)
335 { 341 {
336 exec $mailer, "-s", $subject, "-a", "Content-Type: $content_type", $name or die "Cannot exec $mailer"; 342 my @mailer_options = ( "-s", $subject );
343
344 unless ($legacy_mail)
345 {
346 push @mailer_options, "-a", "Content-Type: $content_type";
347 }
348 exec $mailer, @mailer_options, $name or die "Cannot exec $mailer";
337 } 349 }
338 binmode MAIL, ":utf8"; 350 binmode MAIL, ":utf8";
339 print MAIL join("\n", @text), "\n"; 351 print MAIL join("\n", @text), "\n";