[Fusionforge-commits] FusionForge branch master updated. 65e32a7e64a42efd7db19ffaec32a4c3f2424f5f

Sylvain Beucler beuc-inria at fusionforge.org
Fri May 23 16:04:15 CEST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  65e32a7e64a42efd7db19ffaec32a4c3f2424f5f (commit)
      from  9220458d4c22416dd1cef31efadb9a11fa3fe135 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 65e32a7e64a42efd7db19ffaec32a4c3f2424f5f
Author: Sylvain Beucler <sylvain.beucler at inria.fr>
Date:   Fri May 23 16:03:53 2014 +0200

    scmhook: commit-email.pl: limit e-mail size (e.g. big diffs) to avoid Mailman list size limit / moderation

diff --git a/src/plugins/scmhook/library/scmsvn/hooks/commitemail/commit-email.pl b/src/plugins/scmhook/library/scmsvn/hooks/commitemail/commit-email.pl
index b7d3bdf..0736291 100755
--- a/src/plugins/scmhook/library/scmsvn/hooks/commitemail/commit-email.pl
+++ b/src/plugins/scmhook/library/scmsvn/hooks/commitemail/commit-email.pl
@@ -1,8 +1,8 @@
 #!/usr/bin/env perl
 
-# Note: FusionForge slight change:
-#-$sendmail = "/usr/sbin/sendmail";
-#+$sendmail = $ENV{SENDMAIL} || "/usr/sbin/sendmail";
+# Note: FusionForge changes:
+# - $sendmail = "/usr/sbin/sendmail" => $ENV{SENDMAIL} || "/usr/sbin/sendmail";
+# - use cut_array() to limit body size to ~40KB (default Mailman limit)
 
 # ====================================================================
 # This script is deprecated.  The Subversion developers recommend
@@ -40,6 +40,25 @@
 # history and logs, available at http://subversion.tigris.org/.
 # ====================================================================
 
+sub cut_array
+{
+    my $data_ref = shift @_;
+    my $max_size = shift @_;
+    my @new_data = ();
+    my $line;
+    my $total_size = 0;
+
+    for $line (@{$data_ref}) {
+        $total_size += length ($line);
+        if ($total_size > $max_size) {
+	    push @new_data, "\n[...]";
+            return @new_data;
+        }
+        push @new_data, $line;
+    }
+    return @new_data;
+}
+
 # Turn on warnings the best way depending on the Perl version.
 BEGIN {
   if ( $] >= 5.006_000)
@@ -632,8 +651,8 @@ foreach my $project (@project_settings_list)
         my $command = "$sendmail -f'$mail_from' $userlist";
         if (open(SENDMAIL, "| $command"))
           {
-            print SENDMAIL @head, @body;
-            print SENDMAIL @difflines if $diff_wanted;
+            print SENDMAIL @head, cut_array (\@body, 3000);
+            print SENDMAIL cut_array (\@difflines, 39000) if $diff_wanted;
             close SENDMAIL
               or warn "$0: error in closing `$command' for writing: $!\n";
           }
@@ -649,10 +668,10 @@ foreach my $project (@project_settings_list)
         handle_smtp_error($smtp, $smtp->mail($mail_from));
         handle_smtp_error($smtp, $smtp->recipient(@email_addresses));
         handle_smtp_error($smtp, $smtp->data());
-        handle_smtp_error($smtp, $smtp->datasend(@head, @body));
+        handle_smtp_error($smtp, $smtp->datasend(@head,cut_array(\@body, 3000)));
         if ($diff_wanted)
           {
-            handle_smtp_error($smtp, $smtp->datasend(@difflines));
+            handle_smtp_error($smtp, $smtp->datasend(cut_array(\@difflines, 39000)));
           }
         handle_smtp_error($smtp, $smtp->dataend());
         handle_smtp_error($smtp, $smtp->quit());

-----------------------------------------------------------------------

Summary of changes:
 .../scmsvn/hooks/commitemail/commit-email.pl       |   33 +++++++++++++++-----
 1 file changed, 26 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list