You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Gustavo Delfino <gd...@umich.edu> on 2007/08/12 15:28:04 UTC

hook-script: commit-email.pl

Hello all, in the commit-email.pl hook-script available at:

<http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/commit- 
email.pl.in>

I beleive that a colon is missing after the "From"

Regards,

Gustavo Delfino

***************
*** 549,557 ****
       my $formatted_date;
       if (defined $stdout)
         {
           $formatted_date = strftime('%a %b %e %X %Y', localtime());
!         push(@head, "From $mail_from $formatted_date\n");
         }
       $formatted_date = strftime('%a, %e %b %Y %X %z', localtime());
       push(@head, "Date: $formatted_date\n");
       push(@head, "To: $to\n");
--- 549,557 ----
       my $formatted_date;
       if (defined $stdout)
         {
           $formatted_date = strftime('%a %b %e %X %Y', localtime());
!         push(@head, "From: $mail_from $formatted_date\n");
         }
       $formatted_date = strftime('%a, %e %b %Y %X %z', localtime());
       push(@head, "Date: $formatted_date\n");
       push(@head, "To: $to\n");

Re: hook-script: commit-email.pl

Posted by John Peacock <jp...@rowman.com>.
Gustavo Delfino wrote:
> Then I propose this change in commit-email.pl:
> 
> ***************
> *** 546,554 ****
>         }
> 
>       my @head;
>       my $formatted_date;
> !     if (defined $stdout)
>         {
>           $formatted_date = strftime('%a %b %e %X %Y', localtime());
>           push(@head, "From $mail_from $formatted_date\n");
>         }
> --- 546,554 ----
>         }
> 
>       my @head;
>       my $formatted_date;
> !     if (defined $stdout && $stdout == 1)
>         {
>           $formatted_date = strftime('%a %b %e %X %Y', localtime());
>           push(@head, "From $mail_from $formatted_date\n");
>         }
> 
> Agree? Otherwise my notifications are being send screwed up with double 
>  From headers.

Yes, that is both a correct analysis of the problem and a working 
solution.  I don't have commit access to that part of the repository, so 
please read through:

     http://subversion.tigris.org/hacking.html#patches
and http://subversion.tigris.org/hacking.html#log-messages

and submit a patch to dev@subversion.tigris.org (you don't need to be 
subscribed to post) with a log entry as described above.  Please make 
sure to provide a unified diff (diff -u) as that is much easier to read 
in general (though for a single line change it doesn't make much 
difference).

I'm already committed to rewriting commit-email.pl (but I haven't been 
able to gain much traction recently), but it would be good to get this 
patch into the trunk in case 1.5 comes out before I get it rewritten.

Thanks for researching this and providing the patch...

John

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Boulevard
Suite H
Lanham, MD  20706
301-459-3366 x.5010
fax 301-429-5748

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: hook-script: commit-email.pl

Posted by Gustavo Delfino <gd...@umich.edu>.
OK, I think I understand the problem and would like to propose a  
solution. But first of all, this is how I'm calling the program  
inside post-commit:

/usr/local/svn/gds/hooks/commit-email.pl "$REPOS" "$REV" --from "My  
Server Name <no...@mydomain.com>" -s [abcdefg] gdelfino@umich.com  
(and other addresses)

In the script itself, the only configuration that I did was in line 56:

my $svnlook = "/usr/local/bin/svnlook";

With this configuration emails are being sent with incorrect headers.

Proposed solution:

Considering that in line 208 we have:

             elsif ($arg eq '--stdout')
               {
                 $current_project->{stdout} = 1;
               }

And in line 715 we have:

sub new_project
{
   return {email_addresses => [],
           from_address    => '',
           hostname        => '',
           log_file        => '',
           match_regex     => '.',
           reply_to        => '',
           subject_prefix  => '',
           show_diff       => 1,
           stdout          => 0};
}

And that "defined $stdout" is true when $stdout is equal to number 0

Then I propose this change in commit-email.pl:

***************
*** 546,554 ****
         }

       my @head;
       my $formatted_date;
!     if (defined $stdout)
         {
           $formatted_date = strftime('%a %b %e %X %Y', localtime());
           push(@head, "From $mail_from $formatted_date\n");
         }
--- 546,554 ----
         }

       my @head;
       my $formatted_date;
!     if (defined $stdout && $stdout == 1)
         {
           $formatted_date = strftime('%a %b %e %X %Y', localtime());
           push(@head, "From $mail_from $formatted_date\n");
         }

Agree? Otherwise my notifications are being send screwed up with  
double From headers.

Regards,

Gustavo Delfino

On Aug 12, 2007, at 11:59 AM, John Peacock wrote:
> Gustavo Delfino wrote:
>> John, I made that assumption because somehow the message was actually
>> delivered with the incorrect header. I'll continue to do more  
>> tests to
>> figure out what went wrong.
>
> You need to describe exactly how you executed the script itself  
> (and please keep
> the discussion on the list).  In particular, if you passed --stdout  
> to the
> script, even if you set $sendmail or $smtp_server, then that takes  
> precedence:
>
> # Sendmail path, or SMTP server address.
> # You should define exactly one of these two configuration variables,
> # leaving the other commented out, to select which method of sending
> # email should be used.
> # Using --stdout on the command line overrides both.
> ...
> "  --stdout              Spit the message in mbox format to stdout. 
> \n",
>
> The important clue is that the RFC-2820 "From:" header must contain  
> a true
> e-mail address, e.g.:
>
> 	"John Peacock" <jp...@rowman.com>
>
> and must not contain a formatted date field at all.  If your  
> message had the
> date appended, you called the script erroneously...
>
> John

Re: hook-script: commit-email.pl

Posted by John Peacock <jp...@rowman.com>.
Gustavo Delfino wrote:
> I beleive that a colon is missing after the "From"

You are misunderstanding that code.  If stdout is defined, the assumption is
that the commit-email script is writing directly to an mbox file, which has a
message separator line of

	From [mailfrom] [date]

which is different from the RFC-2820 "From:" header.  This patch should not be
applied...

John

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Blvd
Suite H
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org