I recently migrated our company's svn repositories to a new server and for the most part it works fine. The old main repository was in /var/svn (as in repo files directly in the svn directory), with other repositories setup in /var/reponame, a bit of a messy situation. So when I setup the new server I used /srv/svn/reponame and created symlinks in the old locations. So far so good.
Everything works fine when checking out from svn+ssh://user@server/srv/svn/repo/
(i.e. the real path), but there seems to be a problem with the post-commit hooks when checking out from the symlink (svn+ssh://user@server/var/svn/[...]). For example if you commit with svn ci -m "refs #100"
, it is supposed to update ticket number 100 in trac with the commit comment, but it doesn't unless you are checked out from the actual path.
The username is the same in both cases.
I thought it could be svnserve not obeying the symlink properly so I tried prepending command=/usr/bin/svnserve -r /srv/svn
to the line in authorized_keys as described at http://svnbook.red-bean.com/en/1.5/svn.serverconfig.svnserve.html#svn.serverconfig.svnserve.sshtricks, and checking out from svn+ssh://user@server/reponame/branches/[...]
, however the result is exactly the same.
The contents of the post-commit hook (/srv/svn/reponame/hooks/post-commit) is as follows (comments stripped, names changed):
REPOS="$1"
REV="$2"
LOG=`/usr/bin/svnlook log -r $REV $REPOS`
AUTHOR=`/usr/bin/svnlook author -r $REV $REPOS`
DIFF=`/usr/bin/svnlook diff -r $REV $REPOS`
TRAC_ENV='/srv/trac/sitename'
TRAC_URL='http://server.fqdn/'
/usr/share/subversion/hook-scripts/commit-email.pl "$REPOS" "$REV" user@fqdn
/usr/share/subversion/hook-scripts/code_review_request.php "$REV" "$AUTHOR" "$LOG" "$DIFF"
/usr/local/bin/trac-admin "$TRAC_ENV" changeset added "$REPOS" "$REV"
The commit emails and code review requests are sent which means the hook script is executing, but does anyone know why the calls to trac-admin aren't working?
I have found the solution.
The fix was to alter the post-commit hook, and change the "REPOS" variable to the actual path rather than parse the command line argument ($1):
I assume the reason it wasn't working is because svn is sending the repo path as an argument to the hook script, but trac doesn't know about the /var/svn path - it only knows /srv/svn/reponame.