开发者

subversion post commit hooks

开发者 https://www.devze.com 2023-02-04 05:09 出处:网络
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

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 开发者_JAVA技巧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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号