[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Post-commit issues using commit-email.pl

From: Ryan Schmidt <subversion-2007b_at_ryandesign.com>
Date: 2007-05-10 11:34:48 CEST

On May 9, 2007, at 21:58, Binod wrote:

> Hey Jason thanks so much for your help.
>
> I have few questions though....
> I understood the part of changing
>
> my @project_settings_list = (&new_project);
> to
> my @project_settings_list = ();
> (I believe I give my project name there. For Example if my project
> is in path/to/repos/Project1 , I put Project1 inside the
> brackets..correct me if I am wrong),
>
> Talking about other parameters within commit-email.pl what else
> should I change: I believe the following :
> <<$sendmail= "usr/sbin/sendmail">> --- I uncommented this as I use
> sendmail and gave the proper path for sendmail and
> commented <<#$smtp= " 127.0.0.1">>
>
> For my $svnlook I made following changes << my $svnlook = path/to/
> svnlook>>
>
> I believe I need to make some changes in this particular part of
> the script as well,,(correct me if i am wrong)
> <<my @email_addresses = @{$project->{email_addresses}};
> my $userlist = join(' ', @email_addresses);
> my $to = join(', ', @email_addresses);
> my $from_address = $project->{from_address};>>>
>
> I am confused on all this, Can you explain this please and how to
> configure all these as well, if I have 3 developers group who
> access three different projects within one repos.Where do I define
> the developers group and their email addresses per project.

I find it highly irregular that you're trying to configure commit-
email.pl by editing its source. Surely that shouldn't be necessary.
I've never used it, but let me have a quick look.

Ok. First of all, the definition of $svnlook was already correct in
my version of commit-email.pl, since my package manager took care of
that for me, since that's one of its jobs (making sure all the parts
play nicely with one another). Did your package manager not fix this
properly? If so, please take it up with the developers of your
package manager. If you did not use a package manager but installed
the script manually, then yes, you need to fix up that location
yourself.

Next, I concede that perhaps you need to enable $sendmail (and
disable $smtp_server) by editing the source. I had to do it too.
That's unfortunate; you'd think there would be a command-line
argument or a config file to set that behavior.

Now on to the good stuff. Running commit-email.pl without any
arguments prints out a big fat usage message as follows; please read
all of it:

-----------------------------------------------------------
$ perl commit-email.pl
commit-email.pl: too few arguments.
usage (commit mode):
   commit-email.pl REPOS REVNUM [[-m regex] [options]
[email_addr ...]] ...
usage: (revprop-change mode):
   commit-email.pl --revprop-change REPOS REVNUM USER PROPNAME [-d
diff_file] \
     [[-m regex] [options] [email_addr ...]] ...
options are:
   --from email_address Email address for 'From:' (overrides -h)
   -h hostname Hostname to append to author for 'From:'
   -l logfile Append mail contents to this log file
   -m regex Regular expression to match committed path
   -r email_address Email address for 'Reply-To:'
   -s subject_prefix Subject line prefix
   --diff y|n Include diff in message (default: y)
                         (applies to commit mode only)

This script supports a single repository with multiple projects,
where each project receives email only for actions that affect that
project. A project is identified by using the -m command line
option with a regular expression argument. If the given revision
contains modifications to a path that matches the regular
expression, then the action applies to the project.

Any of the following -h, -l, -r, -s and --diff command line options
and following email addresses are associated with this project. The
next -m resets the -h, -l, -r, -s and --diff command line options
and the list of email addresses.

To support a single project conveniently, the script initializes
itself with an implicit -m . rule that matches any modifications
to the repository. Therefore, to use the script for a single-
project repository, just use the other command line options and
a list of email addresses on the command line. If you do not want
a rule that matches the entire repository, then use -m with a
regular expression before any other command line options or email
addresses.

'revprop-change' mode:
The message will contain a copy of the diff_file if it is provided,
otherwise a copy of the (assumed to be new) property value.
-----------------------------------------------------------

Let me try some examples: Here's a basic post-commit hook to send an
email to "all-commits@example.com" from "<username>@example.com" when
any revision is committed:

-----------------------------------------------------------
#!/bin/sh

REPOS="$1"
REV="$2"

COMMIT_EMAIL="/path/to/commit-email.pl"

"$COMMIT_EMAIL" "$REPOS" "$REV" \
-h example.com \
all-commits@example.com
-----------------------------------------------------------

Here's a more complicated invocation. It sends email to a
hypothetical mailing list "foo-commits@example.org" from
"<username>@example.org" with a reply-to address of another
hypothetical mailing list "foo-discuss@example.org" if the revision
changes something under /foo/ in the repository. Diffs are not
included in the mail. In addition, an email is sent to
tom@example.net, dick@example.net and harry@example.net from
"<username>@example.net" if the revision changes something in /tdh/
in the repository. The subject line of the email is prefixed with the
string "[tdh]". Diffs are sent with this mail because that's the
default. Finally, an email with diffs is sent to "all-
commits@example.com" from "repository@example.com" for every revision.

-----------------------------------------------------------
"$COMMIT_EMAIL" "$REPOS" "$REV" \
\
-m ^/foo/ \
-r foo-discuss@example.org \
-h example.org \
--diff n \
foo-commits@example.org \
\
-m "^/tdh/" \
-h example.net \
-s "[tdh]" \
tom@ryandesign.com \
dick@ryandesign.com \
harry@ryandesign.com \
\
-m . \
--from repository@example.com \
all-commits@example.com
-----------------------------------------------------------

Do you see now? You just provide lots of parameters to the script
when you invoke it from your hook script.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu May 10 11:35:33 2007

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.