Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #5 from vitei/content-type

Changed attached diff Content-Type to text/x-diff
  • Loading branch information...
commit 072808076af4e93fa7861ed5350cc0cba76e84db 2 parents da61b83 + 6314d8a
@theory authored
Showing with 55 additions and 43 deletions.
  1. +1 −0  bin/svnnotify
  2. +18 −8 lib/SVN/Notify.pm
  3. +36 −35 t/options.t
View
1  bin/svnnotify
@@ -79,6 +79,7 @@ svnnotify - Subversion activity notification
-d --with-diff Include the diff in the message.
-a --attach-diff Attach the diff to the message.
-w --diff-switches SWITCHES Switches to pass to C<svnlook diff>.
+ --diff-content-type TYPE Sets the Content-Type for diff attachments.
-R --reply-to ADDRESS Address for use in the Reply-To header.
--add-header NAME=VALUE Add an extra header to the email.
-P --subject-prefix PREFIX String to prepend to the subject.
View
26 lib/SVN/Notify.pm
@@ -386,6 +386,14 @@ C<--no-diff-added>. And who knows, maybe someday it will support the same
options as C<svn diff>, such as C<--diff-cmd> and C<--extensions>. Only
relevant when used with C<with_diff> or C<attach_diff>.
+=item diff_content_type
+
+ svnnotify --diff-content-type 'text/x-diff'
+
+Sets the Content-Type header for attached diffs. The default, if this parameter
+is not passed, is 'text/plain'. This parameter has no effect if '--attach-diff'
+is not specified.
+
=item reply_to
svnnotify --reply-to devlist@example.com
@@ -722,13 +730,14 @@ sub new {
unless $params{revision};
# Set up default values.
- $params{svnlook} ||= $ENV{SVNLOOK} || $class->find_exe('svnlook');
- $params{with_diff} ||= $params{attach_diff};
- $params{verbose} ||= 0;
- $params{encoding} ||= $params{charset} || 'UTF-8';
- $params{svn_encoding} ||= $params{encoding};
- $params{diff_encoding} ||= $params{svn_encoding};
- $params{sendmail} ||= $ENV{SENDMAIL} || $class->find_exe('sendmail')
+ $params{svnlook} ||= $ENV{SVNLOOK} || $class->find_exe('svnlook');
+ $params{with_diff} ||= $params{attach_diff};
+ $params{verbose} ||= 0;
+ $params{encoding} ||= $params{charset} || 'UTF-8';
+ $params{svn_encoding} ||= $params{encoding};
+ $params{diff_encoding} ||= $params{svn_encoding};
+ $params{diff_content_type} ||= $params{diff_content_type} || 'text/plain';
+ $params{sendmail} ||= $ENV{SENDMAIL} || $class->find_exe('sendmail')
unless $params{smtp};
_usage( qq{Cannot find sendmail and no "smtp" parameter specified} )
@@ -880,6 +889,7 @@ sub get_options {
'with-diff|d' => \$opts->{with_diff},
'attach-diff|a' => \$opts->{attach_diff},
'diff-switches|w=s' => \$opts->{diff_switches},
+ 'diff-content-type=s' => \$opts->{diff_content_type},
'reply-to|R=s' => \$opts->{reply_to},
'subject-prefix|P=s' => \$opts->{subject_prefix},
'subject-cx|C' => \$opts->{subject_cx},
@@ -1704,7 +1714,7 @@ sub output_attached_diff {
print $out "\n--$self->{boundary}\n",
"Content-Disposition: attachment; filename=",
"r$self->{revision}-$self->{user}.diff\n",
- "Content-Type: text/plain; charset=$self->{encoding}\n",
+ "Content-Type: $self->{diff_content_type}; charset=$self->{encoding}\n",
($self->{language} ? "Content-Language: $self->{language}\n" : ()),
"Content-Transfer-Encoding: 8bit\n\n";
$self->_dump_diff($out, $diff);
View
71 t/options.t
@@ -18,41 +18,42 @@ my %testopts = (
);
my %params = (
- set_sender => undef,
- smtp => undef,
- smtp_user => undef,
- smtp_pass => undef,
- smtp_port => undef,
- smtp_tls => undef,
- smtp_authtype => undef,
- to_regex_map => undef,
- to_email_map => undef,
- from => undef,
- user_domain => undef,
- encoding => undef,
- svn_encoding => undef,
- diff_encoding => undef,
- language => undef,
- with_diff => undef,
- attach_diff => undef,
- diff_switches => undef,
- reply_to => undef,
- subject_prefix => undef,
- subject_cx => undef,
- no_first_line => undef,
- max_sub_length => undef,
- max_diff_length => undef,
- handler => undef,
- filters => undef,
- author_url => undef,
- revision_url => undef,
- ticket_map => undef,
- ticket_url => undef,
- ticket_regex => undef,
- verbose => undef,
- help => undef,
- man => undef,
- version => undef,
+ set_sender => undef,
+ smtp => undef,
+ smtp_user => undef,
+ smtp_pass => undef,
+ smtp_port => undef,
+ smtp_tls => undef,
+ smtp_authtype => undef,
+ to_regex_map => undef,
+ to_email_map => undef,
+ from => undef,
+ user_domain => undef,
+ encoding => undef,
+ svn_encoding => undef,
+ diff_encoding => undef,
+ language => undef,
+ with_diff => undef,
+ attach_diff => undef,
+ diff_switches => undef,
+ diff_content_type => undef,
+ reply_to => undef,
+ subject_prefix => undef,
+ subject_cx => undef,
+ no_first_line => undef,
+ max_sub_length => undef,
+ max_diff_length => undef,
+ handler => undef,
+ filters => undef,
+ author_url => undef,
+ revision_url => undef,
+ ticket_map => undef,
+ ticket_url => undef,
+ ticket_regex => undef,
+ verbose => undef,
+ help => undef,
+ man => undef,
+ version => undef,
);
while (my ($k, $v) = each %testopts) {
Please sign in to comment.
Something went wrong with that request. Please try again.