You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Archie Cobbs <ar...@dellroad.org> on 2004/08/03 20:54:23 UTC

[PATCH] commit-email.pl 'stop processing' flag

Hi,

Below is a patch to commit-email.pl that allows a project to be given
the '-S' flag which means 'stop processing'. Not the prettiest patch
in the world (I'm a perl-avoider) but it seems to get the job done.

For what it's worth...

The problem
-----------

Some subtrees of our project contain sensitive files. We don't
want commit emails containing diffs of these sensitive files going
to the normal commit email address. Instead, they should be omitted
from the email, or go to a different address that directs them to the
appropriate audience.

There's no way to do this today because the matching algorithm of
commit-email.pl's command line is only "additive".

The ideal solution
------------------

Ideally, it would be nice if you could give commit-email.pl regular
expressions to select out sensitive files whose diffs you don't
want to show in the commit email.

The present solution
--------------------

If a '-m' project is given the '-S' flag, then if it matches processing
stops and subsequent project will not match.

So now if you are not a special person then instead of getting emails
with the sensitive diffs removed (ideal solution), you just don't get
the emails at all (workable solution).

Thanks,
-Archie

P.S. please include my email in replies; I'm not subscribed

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com

Index: tools/hook-scripts/commit-email.pl.in
===================================================================
--- tools/hook-scripts/commit-email.pl.in	(revision 10475)
+++ tools/hook-scripts/commit-email.pl.in	(working copy)
@@ -103,7 +103,8 @@
                        '-l'     => 'log_file',
                        '-m'     => '',
                        '-r'     => 'reply_to',
-                       '-s'     => 'subject_prefix');
+                       '-s'     => 'subject_prefix',
+                       '-S'     => 'stop_processing');
 
 while (@ARGV)
   {
@@ -116,6 +117,13 @@
             die "$0: command line option `$arg' is not recognized.\n";
           }
 
+        # Handle -S
+        if ($arg eq '-S')
+          {
+            $current_project->{$hash_key} = "true";
+            next;
+          }
+
         unless (@ARGV)
           {
             die "$0: command line option `$arg' is missing a value.\n";
@@ -386,6 +394,7 @@
     my $log_file        = $project->{log_file};
     my $reply_to        = $project->{reply_to};
     my $subject_prefix  = $project->{subject_prefix};
+    my $stop_processing = $project->{stop_processing};
     my $subject;
 
     if ($commondir ne '')
@@ -477,6 +486,12 @@
             warn "$0: cannot open `$log_file' for appending: $!\n";
           }
       }
+
+    # Stop processing if requested
+    if ($stop_processing eq 'true')
+      {
+        last;
+      }
   }
 
 exit 0;
@@ -492,6 +507,7 @@
       "  -m regex              Regular expression to match committed path\n",
       "  -r email_address      Email address for 'Reply-To:'\n",
       "  -s subject_prefix     Subject line prefix\n",
+      "  -S                    Stop processing if this project matches\n",
       "\n",
       "This script supports a single repository with multiple projects,\n",
       "where each project receives email only for commits that modify that\n",
@@ -501,7 +517,8 @@
       "Any of the following -h, -l, -r and -s command line options and\n",
       "following email addresses are associated with this project.  The\n",
       "next -m resets the -h, -l, -r and -s command line options and the\n",
-      "list of email addresses.\n",
+      "list of email addresses. If a project has the -S flag set then if\n",
+      "it matches, processing stops so no subsequent projects will match.\n",
       "\n",
       "To support a single project conveniently, the script initializes\n",
       "itself with an implicit -m . rule that matches any modifications\n",
@@ -523,7 +540,8 @@
           log_file        => '',
           match_regex     => '.',
           reply_to        => '',
-          subject_prefix  => ''};
+          subject_prefix  => '',
+          stop_processing => ''};
 }
 
 # Start a child process safely without using /bin/sh.

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

Re: [PATCH] commit-email.pl 'stop processing' flag

Posted by Ben Reser <be...@reser.org>.
On Wed, Sep 01, 2004 at 05:24:11PM -0500, Archie Cobbs wrote:
> Ben Reser wrote:
> > > If a '-m' project is given the '-S' flag, then if it matches processing
> > > stops and subsequent project will not match.
> > 
> > Your change doesn't appear to work quite like you said.  You're checking
> > for the -S after the email has already been sent...
> 
> Yes, but subsequent emails will not be sent, which is the whole point.

I guess I'm reviewing this without the benefit of actually using this
hook script.  Can someone else who actually uses this script review
this?

-- 
Ben Reser <be...@reser.org>
http://ben.reser.org

"Conscience is the inner voice which warns us somebody may be looking."
- H.L. Mencken

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

Re: [PATCH] commit-email.pl 'stop processing' flag

Posted by Archie Cobbs <ar...@dellroad.org>.
Ben Reser wrote:
> > If a '-m' project is given the '-S' flag, then if it matches processing
> > stops and subsequent project will not match.
> 
> Your change doesn't appear to work quite like you said.  You're checking
> for the -S after the email has already been sent...

Yes, but subsequent emails will not be sent, which is the whole point.

-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com

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

Re: [PATCH] commit-email.pl 'stop processing' flag

Posted by Ben Reser <be...@reser.org>.
On Tue, Aug 03, 2004 at 03:54:23PM -0500, Archie Cobbs wrote:
> Hi,
> 
> Below is a patch to commit-email.pl that allows a project to be given
> the '-S' flag which means 'stop processing'. Not the prettiest patch
> in the world (I'm a perl-avoider) but it seems to get the job done.
> 
> For what it's worth...
> 
> The problem
> -----------
> 
> Some subtrees of our project contain sensitive files. We don't
> want commit emails containing diffs of these sensitive files going
> to the normal commit email address. Instead, they should be omitted
> from the email, or go to a different address that directs them to the
> appropriate audience.
> 
> There's no way to do this today because the matching algorithm of
> commit-email.pl's command line is only "additive".
> 
> The ideal solution
> ------------------
> 
> Ideally, it would be nice if you could give commit-email.pl regular
> expressions to select out sensitive files whose diffs you don't
> want to show in the commit email.
> 
> The present solution
> --------------------
> 
> If a '-m' project is given the '-S' flag, then if it matches processing
> stops and subsequent project will not match.
> 
> So now if you are not a special person then instead of getting emails
> with the sensitive diffs removed (ideal solution), you just don't get
> the emails at all (workable solution).

Your change doesn't appear to work quite like you said.  You're checking
for the -S after the email has already been sent...

-- 
Ben Reser <be...@reser.org>
http://ben.reser.org

"Conscience is the inner voice which warns us somebody may be looking."
- H.L. Mencken

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

Re: [PATCH] commit-email.pl 'stop processing' flag

Posted by Michael W Thelen <th...@cs.utah.edu>.
* Archie Cobbs <ar...@dellroad.org> [2004-08-03 15:03]:
> Below is a patch to commit-email.pl that allows a project to be given
> the '-S' flag which means 'stop processing'. Not the prettiest patch
> in the world (I'm a perl-avoider) but it seems to get the job done.

Thanks for the patch!  I've filed it as issue #2004 (good year, btw):
http://subversion.tigris.org/issues/show_bug.cgi?id=2004

-- 
Michael W. Thelen
It is a mistake to think you can solve any major problems just with potatoes.
                -- Douglas Adams