问题
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?
回答1:
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" commit-watchers@example.org
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.
回答2:
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
andColorDiff.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 your.email@address.com \
--from from.email@address.com \
--with-diff \
--subject-cx \
--subject-prefix 'Your Project Name: ' \
--handler HTML::ColorDiff \
--css-inline
2>&1 &
exit 0
回答3:
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
回答4:
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.
来源:https://stackoverflow.com/questions/501692/easiest-best-way-to-set-up-svn-commit-emails