Easiest/best way to set up SVN commit emails?
Asked Answered
R

4

19

I'd like to set up commit emails on a project I'm work on, as described here:
http://producingoss.com/en/vc.html#commit-emails

That is, use a post commit hook to send an email to a list containing the commit title/log and diff of the changes.

What's the easiest way on a Linux machine to set this up?

Ripleigh answered 1/2, 2009 at 22:14 Comment(0)
K
18

When creating new repository a sample post-commit hook is provided in hooks/post-commit.tmpl. It contains a line that looks more or less like this:

/usr/share/subversion/hook-scripts/commit-email.pl "$REPOS" "$REV" [email protected]

Just substitute the email with the address you want to send notifications to, rename the script to hooks/post-commit (remove the tmpl extension) and make it executable (chmod a+x).

When you run the commit-email.pl script without any arguments you will see an usage screen with extra options that allow for example to modify the subject line or the From address.

Please note that is case of Debian the commit-email.pl script is located in an optional subversion-tools package.

Keg answered 1/2, 2009 at 22:42 Comment(1)
Well, this certainly qualifies as "easiest". Thanks!Ripleigh
E
34

Although this question is a bit old, just thought I would leave my opinion for those coming here from Google:

I've considered the solutions mentioned here. The commit-email.pl was both easier and better working for me. However, I find both solutions lacking proper formatting.

Thus, the svnnotify package seems to produce well-enough formatted and colored emails for me.

On Debian/Ubuntu systems you can install it by typing:

apt-get install libsvn-notify-perl

Then, if you are gonna send emails to Gmail accounts, due to odd CSS support in Gmail, I would strongly recommend applying the patch found here, which means:

  • Download HTML.pm and ColorDiff.pm
  • Replace with them /usr/share/perl5/SVN/Notify/HTML.pm and /usr/share/perl5/SVN/Notify/HTML/ColorDiff.pm, respectively.

And finally, setup the post-commit hook script the usual way:

# email notifications for commits
/usr/bin/svnnotify --repos-path "$REPOS" --revision "$REV" \
    --to [email protected] \
    --from [email protected] \
    --with-diff \
    --subject-cx \
    --subject-prefix 'Your Project Name: ' \
    --handler HTML::ColorDiff \
    --css-inline
    2>&1 &

exit 0
Epigraph answered 20/3, 2011 at 16:53 Comment(4)
I wish i cold vote this up twice :-) You get very nice mails this way, thumbs up!Screening
+1 for the --css-inline That should go in to the main SVN NotifySilesia
+1 nice email format. Emails are so nice that you cannot wait to commit !Squawk
Took me an hour to finally make it work. chmodded a lot. The final fix was to add #!/bin/bash to the beginning and replace $REPOS and $REV with $1 and $2Theophilus
K
18

When creating new repository a sample post-commit hook is provided in hooks/post-commit.tmpl. It contains a line that looks more or less like this:

/usr/share/subversion/hook-scripts/commit-email.pl "$REPOS" "$REV" [email protected]

Just substitute the email with the address you want to send notifications to, rename the script to hooks/post-commit (remove the tmpl extension) and make it executable (chmod a+x).

When you run the commit-email.pl script without any arguments you will see an usage screen with extra options that allow for example to modify the subject line or the From address.

Please note that is case of Debian the commit-email.pl script is located in an optional subversion-tools package.

Keg answered 1/2, 2009 at 22:42 Comment(1)
Well, this certainly qualifies as "easiest". Thanks!Ripleigh
T
10

We use svnmailer for this. We symlink our repository-specific post-commit hook scripts to a single script, which in turn calls svnmailer. The configuration is pretty straight forward, and with their simple.conf example configuration you can be up and running in a few minutes. Note that it is written in Python, so that is a prerequisite to installation.

Our entire post-commit hook script is only a few lines (note that you might do other stuff in your post-commit hook, but we currently don't):

#!/bin/sh

CONFIG="/usr/local/svnmailer/default.conf"
MAILER="/usr/bin/svn-mailer"

# These are passed in by subversion
REPOS="$1"
REV="$2"

"${MAILER}" --commit \
            --config "${CONFIG}" \
            --repository "${REPOS}" \
            --revision "${REV}" \
            --background
Tchao answered 1/2, 2009 at 22:17 Comment(2)
If I could have accepted both, I would have. As soon as I find commit-email.pl too limiting, I'm running straight to svnmailer. Thanks again!Ripleigh
Well when you do that, make sure to come back and change your accepted answer ;)Tchao
D
-1

Check the svn-mod-email package described here. The svn-mod-email is a powerful tool for SVN email notifications management that is delivered as a Debian archive. It's easily to install, configure and use.

Damnedest answered 19/6, 2013 at 6:39 Comment(2)
The link is dead !! but not sure why someone down-voted this answer?Cryometer
The link is working again. Thanks for letting me know.Damnedest

© 2022 - 2024 — McMap. All rights reserved.