2
votes

The post-commit hook works fine when I commit changes from the server where SVN and Trac are running. When I commit remotely from my Mac however, the activity shows up in Trac's timeline, but the ticket doesn't get updated.

I've tried this in Netbeans 7 as well as from the command line — same result. I'm logged in with the same username on both server and Mac, although with a different password. I know this shouldn't matter though, because everything had been working fine for months, up until a few days ago.

I'm not sure of what might have changed on my Mac or the server to break this functionality.

Some more info, added 7/26/2011:

On my Mac I'm using svn+ssh://, on the server using file:///

I do have the Trac log level set to DEBUG, but I'm not quite sure what I should be looking for.

My post-commit script appears below. Please note that I know the post-commit itself is working, because the QA update and Campfire post both work. I've also tried outputting $TRAC_ENV, $REPOS, and $REV to a file, and all vars are set properly.

#!/bin/sh

# POST-COMMIT HOOK
#
# The post-commit hook is invoked after a commit.  Subversion runs
# this hook by invoking a program (script, executable, binary, etc.)
# named 'post-commit' (for which this file is a template) with the 
# following ordered arguments:
#
<<<more comments, yada, yada>>>
#
# Here is an example hook script, for a Unix /bin/sh interpreter.
# For more examples and pre-written hooks, see those in
# the Subversion repository at
# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/


REPOS="$1"
REV="$2"
TRAC_ENV=/usr/share/trac/projects/main

#commit-email.pl "$REPOS" "$REV" [email protected]
#log-commit.py --repository "$REPOS" --revision "$REV"

# update the qa working copy
/usr/bin/ruby /usr/local/svn-repo/hooks/scripts/svn-dev-wc-update.rb $REPOS $REV

# send a message to Trac concerning this commit
/usr/bin/trac-admin $TRAC_ENV changeset added $REPOS $REV

# send a message to Campfire's Engineering room
/usr/bin/ruby /usr/local/svn-repo/hooks/scripts/campfire-announce.rb $REPOS $REV 
2
I'd be interested to see what was in the /usr/bin/trac-admin... is that provided by trac? Does it have any options to increase verbosity of it's output? as your hook is written we don't even know if it is exiting successfully... I would suggest capturing it's exit status in a file for now by adding this line below the trac-admin echo $? >> /tmp/trac-admin-return-status what do you get?thekbb

2 Answers

0
votes

Can you post the contents of your post-commit hook script?

When you commit from the server, how are you accessing the repository? Are you using the file:// syntax for the repository, or are you using the same svn+ssh:// URL that you use when committing remotely? Do you get the same results if you try both of these access methods?

Also, try turning Trac's logging options up to the maximum and see if anything useful ends up in the logfile.

0
votes

Old question, but I had the same problem and solved it pretty soon. I only got an error message saying:

Warning: post-commit hook failed (exit code 2) with output:
Error: Command not found

The command that wasn't found was not tracadmin executable. And this didn't happen when I did the commit via https. But what's the difference? The difference is that https commit will call the hooks as the user 'www-data' and svn+ssh commit will use the actual user's account.

I solved this by creating a group called svnwrite, adding myself to it and adding the group write permissions to my trac project directory.