If you are using Subversion/CVS, you might have come across the issue where multiple developers working on a set of files are committing without any comments.

Subversion’s hook scripts provide a powerful way to associate actions with repository events. For example, the pre-commit hook allows you to check — and possibly abort — a transaction before it actually gets committed. I will provide you now two easy Unix bash scripts  that avoid bad developer behaviors:

  • The first one “” is for checking that nobody submit an empty SVN commit comment
  • The second one “” is able to enforce SVN commit comment pattern using regular expressions

Creating and Installing a Hook Script

Your Subversion repository already has some template hook scripts. For example, the pre-commit template is in PATH_TO_REPOS/hooks/pre-commit.tmpl. These templates contain instructions on what the hook script does and what parameters it can expect.

You can hook your own script on the following events

  • start-commit Before the commit transaction starts
  • pre-commit After the commit transaction starts but before the transaction is committed
  • post-commit After the commit transaction completes
  • pre-revprop-change Before a revision property is changed Repository Path,
  • post-revprop-change: After a revision property is changed Repository Path
  • pre-lock:  Before the lock being acquired
  • post-lock:  After the lock being acquired

You’ll find examples in the hook directory named

  • post-commit.tmpl
  • pre-unlock.tmpl
  • post-lock.tmpl
  • pre-commit.tmpl
  • start-commit.tmpl
  • post-revprop-change.tmpl
  • pre-lock.tmpl
  • post-unlock.tmpl
  • pre-revprop-change.tmpl

If you cant find them, brute force your server to locate them

# find / –name pre-commit


# locate pre-commit

On Debian you will find them at


Create a file pre-commit with that content, nothing force you to put a huge bash script in pre-commit. In my example below, I prefer to divide pre-commit checks in multiple files. The pre-commit hook gives you a way to catch the transaction before it becomes a revision. Subversion passes this hook two parameters:

  1. the path to the root of the repository
  2. the transaction identifier
set -e
/data/svn-repos/{yourRepository}/hooks/ "$1" "$2"
/data/svn-repos/{yourRepository}/hooks/ "$1" "$2"

Note that after installation, every commit will run these two scripts. Check your permissions, scripts have to be runnable for the user (www-data on debian)

Avoid empty comment in SVN commits

Save this file in /data/svn-repos/{yourRepository}/hooks/


if [`$SVNLOOK log -t $TXN $REPOS` != ""]; then
  echo "" 1>&2
  echo "*** Your commit has been blocked because you did not give any log message or your log message was too short." 1>&2
  echo "Please write a log message describing the purpose of your changes and then try committing again." 1>&2
  exit 1
  exit 0

Example in Eclipse, if you break the rule


Enforce SVN commit comment pattern using regular expressions

Save this file in /data/svn-repos/{yourRepository}/hooks/

This script use Bash script REGEX capabilities, I check against what could be a typical JIRA issues entry

If any developer try to use a commit statement not starting with for example PRODUCT-xxxx, the commit will be blocked.


if [[ `$SVNLOOK log -t $TXN $REPOS` =~ ${regex} ]]; then
  exit 0
  echo "" 1>&2
  echo "*** Your commit has been blocked because you give an invalid commit comment" 1>&2
  echo "Please make your commit comment start with PRODUCT-XXX" 1>&2
 exit 1

Example in Eclipse, if you break the rule


Want more?

You can automated code reviews with Checkstyle using pre-commit script and so Stop rule-breaking code before it enters your code base!


hook_scripts" target="_blank"> List of some Hook scripts examples written in python/bash

You might like also

PuTTYCS - PuTTY Command Sender 1.8.1
PuTTYCS is a small windows application that is intended to be used along with multiple instances of PuTTY (including PuTTYtel, TuTTY, and PieTTY). It's purpose is to send the same command to each PuTTY window. It is can be useful for copying files, starting and stopping processes, and examining logs on multiple servers. If you're not familiar with PuTTY, then this tool is probably not for you. If you want to find out more about PuTTY, visit PuTTY at …
1732 Days ago
Search And Replace Within Zip Files with Regular Expressions
There is a lot of shareware and freeware (jEdit, Notepad++) to do complex search and replacement in files but none is supporting these kind of operations in zip files spread across many subdirectories. Luckily Oxygen Editor can Do case sensitive or insensitive searches, Search and replace across multiple files in multiple subdirectories, Search and replace also in ZIP files, Advanced regular expression search/replace, Is free to evaluate for 30 days! Use the Menu "Find" and select "Replace in Files" or …
2946 Days ago
The Build Tool Report: Turnaround Times using Ant, Maven, Eclipse, IntelliJ, and NetBeans
          Even if the sample is quite small (600 responses), it still interesting going through these compiled data Some time ago we ran a survey asking a few questions about the build process, specifically the tools that are used to do incremental builds and how much time those builds take. We had over 600 responses, so now it’s time to count the results. This is the first time that we’ve published results on the incremental build …
3771 Days ago
Web page as Graphs with source code
Webpages as Graphs With this funny applet, you can judge of the complexity of a web page by just generating it’s graph! my homepage is way too complex compare to google for example :-) What do the colors mean? blue: for links (the A tag) red: for tables (TABLE, TR and TD tags) green: for the DIV tag violet: for images (the IMG tag) yellow: for forms (FORM, INPUT, TEXTAREA, SELECT and OPTION tags) orange: for linebreaks and blockquotes …
3917 Days ago
Atlassian just acquired GreenHopper
Atlassian just acquired GreenHopper, a popular JIRA plugin with over 800 customers. GreenHopper is a JIRA plug-in that adds a broad collection of agile project management capabilities to JIRA, and extends JIRA as a powerful platform for agile development teams. GreenHopper simplifies the planning and organization of tasks, workflows and reporting for agile teams. It introduce in JIRA Card management:  Visualise issues, tasks and user stories as graphical "cards", color-coded and dynamically editable. Planning Board: Quickly create, assemble, sort and …
3920 Days ago
No Thumbnail was found
Keyboard ShortcutsFilesControl-NNew file.Control-OOpen file.Control-WClose buffer.Control-E Control-WClose all buffers.Control-SSave buffer.Control-E Control-SSave all buffers.Control-PPrint buffer.Control-Page UpGo to previous buffer.Control-Page DownGo to next buffer.Control-`Go to recent buffer.Control-QExit jEdit.ViewsControl-E Control-TTurn gutter (line numbering) on and off.Control-2Split view horizontally.Control-3Split view vertically.Control-1Unsplit.Alt-Page UpSend keyboard focus to previous text area.Alt-Page DownSend keyboard focus to next text area.Control-E Control-Up; Control-Left; Control-Down; Control-RightSend keyboard focus to top; bottom; left; right docking area.Control-E Control-`Close currently focused docking area.Control-E Control-ESend keyboard focus back to current text area.RepeatingControl-EnternumbercommandRepeat the command (it can …
5330 Days ago
No Thumbnail was found
"For more than 50 years software has been a troublesome discipline. Software's problems are numerous and include cancelations, litigation, cost overruns, schedule overruns, high maintenance costs, and low levels of user satisfaction. The problems with software occur more often than not. My company's research indicates that more than half of large software projects will encounter some kind of delay, overrun, or failure to perform when deployed. But software does not have to be as troublesome as it has been. …
5572 Days ago
No Thumbnail was found
TCPviewer dsplay TCP connections in realtime and ProcessXP shows all processes and their dependant dll loaded into memory... GIMP can replace photoshop, open source free, it can replace any graphic editor TCP proxy is a tool part of Soap AXIS, useful to show SOAP request and response or any process using TCP connection. Jedit, the BEST text editor ever written!!!! Beyond Compare for comparing directories, files. Do a lot of things, you will never forget this name!!!! …
5638 Days ago