Post commit hook for Windows with multiple project support
|Reported by:||Owned by:||Jonas Borgström|
I have been using Subversion for a while now, but just started using Trac. Way back when, I choose the single repository model and haven't thought twice about it until I discovered Trac. Here's an idea of my layout:
After investigating the available options, I decided to keep the single repository (dump/load is just too much work) but create multiple trac environments for the projects or in some cases the Category or SubCategory level. The problem with this is now the post-commit hooks from Tickets #897 and #1602 won't work since only one trac env can be used (this is mentioned in #897 but no solution was posted).
My solution is to use the svnlook changed command and look for project names in the path and map to my new trac environments. I haven't tried python yet, but am familar with NSIS so I built a "silent" installer that:
- Reads the command line to get REPOS and TXN
- Execute the same svnlook commands as the hooks from #897 and #1602
- Execute svnlook changed command and parse for SVN project names
- Optionally parse svnlook changed output for a tagged RELEASE*
- Create new version using trac-admin for the RELEASE*
The parameters are configurable through the post-commit.ini file
[path] SVN=C:\Program Files\Subversion Python=C:\Python23 Trac_Env=D:\trac SVNREP=D:\SVN_REPOS\MyProjects TRAC_ADMIN=C:\Python23\Scripts [ProjectMap] SVN0=Category1/SubCategory/Project1/ trac0=Project1 SVN1=Category2/Project2/ trac1=Project2 . . . SVNn=... tracn=... [CreateVersion] CheckForRelease=true ReleaseString=/tags/RELEASE_ [Debug] WriteReturn=false
- The string match function is not very smart (no regex in NSIS) so make the SNV project string as explicit as possible (the example above could even include the trunk such as SVN0=Category1/SubCategory/Project1/trunk/) to avoid false matches
- The ProjectMap section must contain SNVn/tracn pairs where n starts at 0 and increments by 1.
- The debug option is not meant to be left on
- The mapping feature allows trac projects (envoronments) to be named different than the corresponding SVN projects.
- There is minimal error checking at this point
- There are three files required for this to work
- The post-commit.nsi is included incase anyone wants to modify it
*I got the idea for the "new version" from tagged release from http://trac-hacks.org/wiki/SvnPostCommitCreateVersionScript which also solves the multiple project issue (but only if every project in the REPOS has a corresponding trac project).