On CBSSports.com: New Maxim Hometown Hotties here each day

Running hook scripts in subversion

Tags: E-mail, Linux, Subversion, Vincent Danen, subversion repository, Linux Tips Newsletter

  • Save
  • Print
  • Digg This
  • 2

Takeaway: Vincent Danen explains how hook scripts work to make subversion an easy and efficient version control system.

Subversion is a great version control system, particularly in the ease with which it processes data at various points of the repository management process. You can have scripts handle data after a commit has been made, before a commit has been made, on locking or unlocking files, and so forth. All of this is done via hooks, which are part of the subversion repository structure itself. Hooks are triggered by a repository event. For instance, if you had a subversion repository as /subversion/repos/packages then the hooks would be in the /subversion/repos/packages/hooks directory.

In this hooks directory are a number of template files. These files exist as examples only. So if you wanted to write a script that would e-mail some subversion data to you on every commit, you would copy the post-commit.tmpl file to post-commit, make it executable, and edit it as needed.

A number of these scripts are available from the subversion site, as well as other user-contributed scripts and tools for subversion. You can view many of these scripts at http://subversion.tigris.org/tools_contrib.html. Of interest at the moment is the post-commit e-mail script, commit-email.pl. Download the file and place it somewhere such as /usr/local/bin/ and make it executable. In the hooks/post-commit script, add to the end of the file the following:

REPOS="$1"
REV="$2"
 
/usr/local/bin/commit-email.pl "$REPOS" "$REV" --from svn@myhost.com -s \
  "SVN commit in packages" joe@myhost.com

This will execute the commit-e-mail.pl script with a few parameters, namely the repository name and the revision of the commit. It will send the e-mail from svn@myhost.com with the specified subject line, and send the mail to joe@myhost.com; this could be either a specific user or a mailing list.

If you look at the other scripts on the site, you'll see a number of scripts that could be of interest in the management of your subversion repository. There are scripts that can do certain checks prior to even fully committing the data to subversion, such as the various pre-commit check scripts.

Delivered each Tuesday, TechRepublic's free Linux NetNote provides tips, articles, and other resources to help you hone your Linux skills. Automatically sign up today!

  • Save
  • Print
  • Digg This
  • 2

What do you think?

Article Categories

Security
Security Solutions, IT Locksmith
Networking and Communications
E-mail Administration NetNote, Cisco Routers and Switches
CIO and IT Management
Project Management, CIO Issues, Strategies that Scale
Desktops, Laptops & OS
Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
Data Management
Oracle, SQL Server
Servers
Windows NT, Linux NetNote, Windows Server 2003
Career Development
Geek Trivia
Software/Web Development
Web Development Zone, Visual Basic, .NET

advertisement
Click Here