I’m running in a windows environment with Trac / SVN and I want commits to the repository to integrate to Trac and close the bugs that were noted in the SVN Comment.
I know there’s some post commit hooks to do that, but there’s not much information about how to do it on windows.
Anyone done it successfully? And what were the steps you followed to achive it?
Here’s the hook I need to put in place in SVN, but I’m not exactly sure how to do this in the Windows environment.
Alright, now that I’ve got some time to post my experience after figuring this all out, and thanks to Craig for getting me on the right track. Here’s what you need to do (at least with SVN v1.4 and Trac v0.10.3):
%~dp0\trac-post-commit-hook.cmd %1 %2
The most important parts here are to set your TRAC_ENV which is the path to the repository root (SET TRAC_ENV=C:\trac\MySpecialProject)
The next MAJORLY IMPORTANT THING in this script is to do the following:
if you see in the script file above I’m using svnlook (which is a command line utility with SVN) to get the LOG message and the author that made the commit to the repository.
Then, the next line of the script is actually calling the Python code to perform the closing of the tickets and parse the log message. I had to modify this to pass in the Log message and the author (which the usernames I use in Trac match the usernames in SVN so that was easy).
The above line in the script will pass into the python script the Trac Environment, the revision, the person that made the commit, and their comment.
Here’s the Python script that I used. One thing that I did additional to the regular script is we use a custom field (fixed_in_ver) which is used by our QA team to tell if the fix they’re validating is in the version of code that they’re testing in QA. So, I modified the code in the python script to update that field on the ticket. You can remove that code as you won’t need it, but it’s a good example of what you can do to update custom fields in Trac if you also want to do that.
I did that by having the users optionally include in their comment something like:
I then use the same technique that the python script uses with regular expressions to get the information out. It wasn’t too bad.
Anyway, here’s the python script I used, Hopefully this is a good tutorial on exactly what I did to get it to work in the windows world so you all can leverage this in your own shop…
If you don’t want to deal with my additional code for updating the custom field, get the base script from this location as mentioned by Craig above (Script From Edgewall)