From c634471607cd83605fc334195514f136d90812d9 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Tue, 4 Feb 2014 16:08:33 +0100 Subject: git-notify: Use committer's name in "From:" header Use the committer's real name in the "From:" header of commit notifications. This is a provisional solution. We'd really like to teach Mailman to also accept the committer's email address. diff --git a/libexec/git-notify b/libexec/git-notify index 8c6400a..64da7c0 100755 --- a/libexec/git-notify +++ b/libexec/git-notify @@ -44,7 +44,8 @@ sub get_repos_name(); # # FIXME: Turn this into a proper git-notify option. # -my $from = "Git Repository "; +my $from_address = "git\@monitoring-plugins.org"; +my $from = "Git Repository <$from_address>"; # some parameters you may want to change @@ -323,14 +324,14 @@ sub parse_options() } # send an email notification -sub mail_notification($$$@) +sub mail_notification($$$$@) { - my ($name, $subject, $content_type, @text) = @_; + my ($from, $to, $subject, $content_type, @text) = @_; - $subject = "[$repos_name] $subject" if ($emit_repo and $name ne $cia_address); + $subject = "[$repos_name] $subject" if ($emit_repo and $to ne $cia_address); $subject = encode("MIME-Q",$subject); - my @header = ("From: $from", "To: $name", "Subject: $subject", "Content-Type: $content_type"); + my @header = ("From: $from", "To: $to", "Subject: $subject", "Content-Type: $content_type"); if ($debug) { @@ -438,7 +439,7 @@ sub send_ref_notice($$@) "", "The $refname $reftype has been $action."); - mail_notification($commitlist_address, "$refname $reftype $action", + mail_notification($from, $commitlist_address, "$refname $reftype $action", "text/plain; charset=us-ascii", @notice); } @@ -515,7 +516,8 @@ sub send_commit_notice($$) $subject .= truncate_str(${$info{"log"}}[0],50); $_ = decode($info{"encoding"}, $_) for @notice; - mail_notification($commitlist_address, $subject, "text/plain; charset=UTF-8", @notice); + mail_notification("$info{'committer_name'} <$from_address>", $commitlist_address, $subject, + "text/plain; charset=UTF-8", @notice); } # send a commit notice to the CIA server @@ -571,7 +573,7 @@ sub send_cia_notice($$) " " . $info{"author_date"} . "", ""; - mail_notification($cia_address, "DeliverXML", "text/xml", @cia_text); + mail_notification($from, $cia_address, "DeliverXML", "text/xml", @cia_text); } # send a global commit notice when there are too many commits for individual mails @@ -585,7 +587,7 @@ sub send_global_notice($$$) $rev =~ s/^commit /URL: ${gitweb_url}\/commit\/?id=/ if $gitweb_url; } - mail_notification($commitlist_address, "New commits on branch $ref", "text/plain; charset=UTF-8", @$notice); + mail_notification($from, $commitlist_address, "New commits on branch $ref", "text/plain; charset=UTF-8", @$notice); } # send all the notices -- cgit v0.10-9-g596f