Subversion Repository Hook : commit-email
Description:
This Post-Commit hook can be used to send a notification email describing either a commit or a revprop-change action on a Subversion repository.
Installation:
These instructions assume that you are using the subversion command line interface on a Unix system. Your process may be slightly different depending on client and operating system.
- Check out your /rice-config repository folder
svn co https://svn.rice.edu/r/REPONAME/rice_config
- Change to the rice_config folder
cd rice_config/
- Create a folder called hooks if one does not already exist
mkdir hooks/
- Change into the hooks folder
cd hooks/
- Create a file called commit-email (See the Configuration section below)
vi commit-email
- Add the directory and file to the repository
cd .. svn add hooks svn commit -m "Added commit-email hook to the repository"
Configuration
The commit-email hook requires some configuration. Within the commit-email file you need to put arguments that tell the script what you want to notify on and who to notify. It will look similar to this:
no_diff_deleted=0 no_diff_added=0 limit_diff_output=0 notify.0.email_addresses = user1@rice.edu notify.0.from_address= fromuser1@rice.edu notify.0.reply_to = user1@pobox.com notify.0.subject_prefix = Any PROJECT COMMIT: notify.0.show_diff = 1 notify.1.email_addresses= user1@rice.edu, user2@rice.edu,user3@pobox.com notify.1.from_address= user4@pobox.com notify.1.match_regex= project1/ notify.1.reply_to = user4@pobox.com notify.1.subject_prefix = PROJECT1 COMMIT: notify.1.show_diff = 0 notify.1.show_author = 1
Argument Descriptions
- no_diff_deleted -
By default, when a file is deleted from the repository, svnlook diff
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_deleted to 1.
- no_diff_added -
By default, when a file is added to the repository, svnlook diff
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.
- limit_diff_output -
By default, if you have diff output turned on, it will log the
entire svnlook diff output in the email. Using this option, you
can limit this diff output to a specific number of lines. All lines
beyond this point will be left out of the email but still be available
using normal subversion client access. Setting limit_diff_output to
0 will display all lines.
Tagged Arguments
Tagged Arguments require the word notify. and some unique value also followed by a dot to prepend the argument. This is used to group all of the arguments together.
- email_addresses -
This can be a single email address or multiple email addresses separated with commas. These are the addresses that the email message will be sent to. If this tagged argument is omitted from the project configuration; email will be sent back to the committer only.
- from_address -
This is a single email address. It will be the From: address specified in the email. If you leave this entry out, the From address of the sent email will be the committer's netid followed by @rice.edu
- match_regex -
This is a regular expression used to match locations within the repository. When changes occur within these locations, emails will be sent. Do not use a leading /. If you want to anchor the pattern to the top of the repository use the ^. If you leave this argument out, it will default to matching the entire repository.
- reply_to -
This is a single email address. It will be the Reply-To: address specified in the email.
- subject_prefix -
This is a short string. It will be prepended to the subject line.
- show_diff -
This is a 1 or a 0. It indicates whether to display the diffs of changed files.
- show_author -
This is a 1 or a 0. It indicates whether to display the author of the change in the subject line.