tags:

views:

222

answers:

3

I'm just trying to hook Trac/SVN together so that my SVN commits manage my Trac Tickets. I've read the documentation and understand (kind of) that the ticket updates rely on a dev using the correct syntax in the comments field which not to put to fine a point on it I think is um... lets use the world unreliable to avoid offending anyone unnecessarily :P

I'm looking at adding a custom field to do this which won't require knowledge of specific syntax in order to update the tickets. The only issue is, I don't have the first clue where to start... I've never even programmed in Python before and while I can kind of interpret what's going on in any given script, I don't want to have to learn the whole language just to integrate the two systems together more robustly.

I have very little *NIX experience, I'm a Microsoft Developer so having to hack all these technologies together via the command line, scripts and configuration files is an environment that's somewhat alien to me.

So has anyone modified Trac/SVN in this fashion or done anything like this before and if so, is there a document or helpful user somewhere that would walk me through this process?

Edit: Should I be considering modifying my SVN client integration to make this process more intuitive for the developer rather than modifying the link between SVN/Trac? Perhaps this would be a more suitable route?

+3  A: 

Pre-commit hooks to check that the syntax of the commit message corresponds with a valid ticket using regular expressions is your best bet. Found a blog entry here that points to most of the relevant sites blog entry

Rob Spieldenner
Could this be set to return an "invalid comment syntax" response and thus prevent the commit? What I'm trying to avoid is allowing for the developer to commit an update without providing a ticket number but not requiring that they understand and use a specific syntax.
BobTheBuilder
A Pre-commit hook is basically a python script that returns a boolean. If the pre-commit fails the commit will not take. I'm not sure of the error message off the top of my head (if any).
Rob Spieldenner
I will check into it, thanks
BobTheBuilder
Anything the hook prints to stdout is forwarded back to the client. I've used pre-commit hooks to refuse tabs or absolute paths in files, detailing offending file and line in the message.
Marcus Lindblom
You can see some examples here: http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
RjOllos
A: 

You should get this for free with trac, simply include the ticket number in your SVN message:

svn commit -m "#635 bugfix"

trac would recognize that the commit belongs to ticket #635 and should make the link, what else do you want the "link" to do? automatically close the ticket?

mmattax
I guess I could have AnkhSVN push this if we create our own branch that does this. I was looking for a more intuitive method of developers providing the ticket information rather than requiring them to remember specific syntaxes to provide in the message which frankly is hokey.
BobTheBuilder
And no, a developer shouldn't be able to close a ticket, but it should automatically change the "Open" status to "InTest" status indicating that it has been fixed and is now in test. The tester would then update the status to "TestSuccess" and then the project manager would review it and mark it as "Complete" if they were satisfied with the fix. If the test failed, then the tester would mark it as "TestFail" and the ticket would then be picked up again for further development.
BobTheBuilder
I'm beginning to wonder if this isn't a problem with the client software rather than the link between Trac/SVN. Perhaps I should pursue this route instead.
BobTheBuilder
Actually there is no problem with a commit comment closing a trac ticket. We do it all the time. Example at http://dancingpenguinsoflight.com/2009/01/updating-trac-tickets-in-svn-commits/
demoncodemonkey
The syntax shown above is not valid for the post-commit hook provided by Trac. You can see valid syntax here: http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook
RjOllos
+1  A: 

I'm a bit late to this party, but is a very useful page that details exactly what you're talking about.

It allows you to set a property that highlights the bug number and turns it into a hyperlink to the bugtracking page when viewed in tortoisesvn (using regular expressions and svn properties). Also say you can get/develop plugins for tortoisesvn which allow you to pick a bug from a list. There's probably one for trac, but I don't know where it is or how good it is.

Combine either of these with the server side hook to disallow committing without the bug number, and you've got a pretty good system.

http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-bugtracker.html

Update: A quick google reveals that TracExplorer may be your best bet for this.

Jim T
Here is another reference for setting up TortoiseSVN and TracExplorer with Trac: http://trac.edgewall.org/wiki/TortoiseSvn
RjOllos