Mar/09
9
Using pre commit hooks to integrate SVN with project management tools
0 Comments | Posted by Žilvinas Šaltys in Tools
Most developer teams work with version control tools like SVN or Git. Most of those teams use certain project management tools like Basecamp or Fogbugz in our case.
We came up with an idea to require developers to write down SVN revision numbers in commit messages. This helps to relate code changes to actual tasks if such a need arises. To do that we’ve created a pre commit hook that requires developers to insert internal project management tool task number to the SVN commit comment field.
A pre commit hook can be a simple bash script. In our case it was this script:
#!/bin/sh REPOS="$1" TXN="$2 # Make sure that the log message contains some text. SVNLOOK=/usr/bin/svnlook $SVNLOOK info -t "$TXN" "$REPOS" | grep -P 'FB:\s*\d{3,6}' > /dev/null if [ $? -ne 0 ]; then echo -e "FogBugz case number is missing in the comment.\n" 1>&2 echo -e "Please add text 'FB: CASE_NUMBER' to your comment." 1>&2 exit 1 fi exit 0