Question

I've got a situation where I'm contemplating using subversion/svn as the repository/version control system for a project. I'm trying to figure out if it's possible, (and if so, how) to be able to have the subversion system, on a post commit hook/process to to write the user/file/time (and maybe msg) to either an external file (csv) or to a mysql db.

Once I can figure out how to invoke the post commit hook to write the output to a file, I can then modify my issue tracker/project app to then implement a basic workflow process based on the user role, as well as the success/failure of the repository files.

Short sample/pointers would be helpful.

My test env, is running subversion/svnserve on centos5. The scripting languages in use are Php/Python.

Was it helpful?

Solution

I would say that's possible, but you are going to need a bit of work to retrieve the username, date and commit message.

Subversion invokes the post-commit hook with the repo path and the number of revision which was just committed as arguments.

In order to retrieve the information you're looking for, you will need to use an executable by the name of svnlook, which is bundled with Subversion.

See repo\hooks\post-commit.tmpl for a rather clear explanation about how to use it

Also, take a look at svnlook help, it's not difficult to use.

OTHER TIPS

Indeed it is very possible, in your repository root there should be a folder named hooks, inside which should be a file named post-commit (if not, create one), add whatever bash code you put there and it will execute after every commit.

Note, there are 2 variables that are passed into the script $1 is the repository, and $2 is the revision number (i think), you can use those two variables to execute some svn commands/queries, and pull out the required data, and do with it whatever your heart desires.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top