Re: post-commit msgs to -devel lists w/ full diff and commit msg



On Jan 2, 2008 9:23 PM, Gabriel Burt <gabriel burt gmail com> wrote:
> On Jan 2, 2008 9:21 PM, Gabriel Burt <gabriel burt gmail com> wrote:
> > I propose that we keep things working exactly like they currently do,
> > with the exception that if you put your module/project into a special
> > plain text file in svn, you will get full diffs in your svn-commits
> > topic.
>
> Just to be clear, I am volunteering to implement my proposal too.

I have attached a patch that implements this.  I tested it on my
machine with a fake repository and it functions well.

Gabriel
--- gnome-commit-email.pl.orig	2008-01-03 12:04:26.000000000 -0600
+++ gnome-commit-email.pl	2008-01-03 13:47:36.000000000 -0600
@@ -56,7 +56,7 @@
 # prints the entire contents of the file.  If you want to save space
 # in the log and email messages by not printing the file, then set
 # $no_diff_added to 1.
-my $no_diff_added = 1;
+my $no_diff_added = 0;
 
 # End of Configuration section.
 ######################################################################
@@ -188,6 +188,21 @@
     &usage("$0: repos directory `$repos' is not a directory.");
   }
 
+# Load project settings from file
+open(IN, "projects");
+while (my $line = readline(IN)) {
+    if ($line =~ /^ ([^#]\S+) \s* : \s* (\S+) /x) {
+        my $project = &new_project;
+        $project->{module_name} = $1;
+        $project->{reply_to} = $2;
+        $project->{include_diff} = 1;
+        $project->{email_addresses} = $current_project->{email_addresses};
+        #$project->{match_regex} = "(\/po\/){0}";
+        unshift(@project_settings_list, $project);
+    }
+}
+close(IN);
+
 # Check that all of the regular expressions can be compiled and
 # compile them.
 {
@@ -293,9 +308,6 @@
 # Get the diff from svnlook.
 my @no_diff_deleted = $no_diff_deleted ? ('--no-diff-deleted') : ();
 my @no_diff_added = $no_diff_added ? ('--no-diff-added') : ();
-#my @difflines = &read_from_process($svnlook, 'diff', $repos,
-#                                   '-r', $rev, @no_diff_deleted,
-#                                   @no_diff_added);
 
 ######################################################################
 # Modified directory name collapsing.
@@ -350,14 +362,14 @@
 ######################################################################
 # Assembly of log message.
 
-my $project = basename($repos);
+my $module = basename($repos);
 
 # Put together the body of the log message.
 my @body;
 push(@body, "Author: $author\n");
 push(@body, "Date: $date\n");
 push(@body, "New Revision: $rev\n");
-push(@body, "ViewCVS link: http://svn.gnome.org/viewcvs/$project?rev=$rev&view=rev\n";);
+push(@body, "ViewCVS link: http://svn.gnome.org/viewcvs/$module?rev=$rev&view=rev\n";);
 push(@body, "\n");
 if (@adds)
   {
@@ -380,24 +392,34 @@
 push(@body, "Log:\n");
 push(@body, @log);
 push(@body, "\n");
-# push(@body, map { /[\r\n]+$/ ? $_ : "$_\n" } @difflines);
 
 # Go through each project and see if there are any matches for this
 # project.  If so, send the log out.
 foreach my $project (@project_settings_list)
   {
-    my $match_re = $project->{match_re};
-    my $match    = 0;
-    foreach my $path (@dirschanged_orig, @adds, @dels, @mods)
-      {
-        if ($path =~ $match_re)
+    if ($project->{module_name} =~ /\w/) {
+        next unless $project->{module_name} eq $module;
+    } elsif ($project->{module_name} ne $module) {
+        my $match_re = $project->{match_re};
+        my $match    = 0;
+        foreach my $path (@dirschanged_orig, @adds, @dels, @mods)
           {
-            $match = 1;
-            last;
+            if ($path =~ $match_re)
+              {
+                $match = 1;
+                last;
+              }
           }
-      }
 
-    next unless $match;
+        next unless $match;
+    }
+
+    if ($project->{include_diff}) {
+        my @difflines = &read_from_process($svnlook, 'diff', $repos,
+                                           '-r', $rev, @no_diff_deleted,
+                                           @no_diff_added);
+        push(@body, map { /[\r\n]+$/ ? $_ : "$_\n" } @difflines);
+    }
 
     my @email_addresses = @{$project->{email_addresses}};
     my $userlist        = join(' ', @email_addresses);
@@ -408,16 +430,15 @@
     my $reply_to        = $project->{reply_to};
     #my $subject_prefix  = $project->{subject_prefix};
     my $subject_prefix  = "";
-    my $project         = basename($repos);
     my $subject;
 
     if ($commondir ne '')
       {
-        $subject = "$project r$rev - in $commondir: $dirlist";
+        $subject = "$module r$rev - in $commondir: $dirlist";
       }
     else
       {
-        $subject = "$project r$rev - $dirlist";
+        $subject = "$module r$rev - $dirlist";
       }
     if ($subject_prefix =~ /\w/)
       {
@@ -439,8 +460,8 @@
     push(@head, "From: $mail_from\n");
     push(@head, "Subject: $subject\n");
     push(@head, "Reply-to: $reply_to\n") if $reply_to;
-    push(@head, "X-SVN-Module: $project\n");
-    push(@head, "Keywords: $project\n");
+    push(@head, "X-SVN-Module: $module\n");
+    push(@head, "Keywords: $module\n");
 
     ### Below, we set the content-type etc, but see these comments
     ### from Greg Stein on why this is not a full solution.
@@ -503,6 +524,7 @@
             warn "$0: cannot open `$log_file' for appending: $!\n";
           }
       }
+    last;
   }
 
 exit 0;
@@ -544,11 +566,13 @@
 sub new_project
 {
   return {email_addresses => [],
+          module_name     => '',
           from_address    => '',
           hostname        => '',
           log_file        => '',
           match_regex     => '.',
           reply_to        => '',
+          include_diff    => 0,
           subject_prefix  => ''};
 }
 
--- /dev/null	2007-12-22 01:09:22.000000000 -0600
+++ projects	2008-01-03 13:51:50.000000000 -0600
@@ -0,0 +1,8 @@
+# This file contains a list of modules for which GNOME's svn-commits list
+# includes full diffs (as opposed to the default, just including a link).
+#
+# Format:
+# module : reply-to-address
+
+banshee             : banshee-devel-list gnome org
+f-spot              : f-spot-list gnome org


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]