Visual SVN Server: Guide on Pre/Post Commit Hooks

大憨熊 提交于 2019-12-07 14:08:54

问题


This may be best as a wiki, given comments on here: Share common / useful SVN pre-commit hooks

I'm using Visual SVN 2.1.7 on a Windows 7 machine. We have developers committing from various countries and we can manage the code changes by running local copies of the changes and then uploading manually via ftp to the server for each website that's being worked on.

This is an incredibly time consuming process, but less time-consuming than fixing bugs on live sites, so it's a step in the right direction.

On the Visual SVN website it makes a mention of post-commit and pre-commit hooks but fails to show where that can be accessed, even though it mentions there is a GUI. There's no sign of a GUI or even an option in the installed version, so I can't locate, firstly, where to access it.

Assuming it can be done via scripting, I have googled and come to SO to look for some guidance on where it might be and how it might be done, but it seems to be a lot more complicated than I'd hoped.

Does anyone have any experience or guidance, including sample scripts, for how to perform the following tasks on Windows (without perl installed)?

a) Create a pre-commit command/file and attach its execution to a repository/commits to it b) Create a post-commit command/file and attach its execution to a repository/commits to it

and in my case, one specific task: c) How to have a local Visual SVN installation on a PC that can send committed files to remote CentOS shared hosted server (not VPS/Dedi or Cloud hosted and SVN can't be installed on those machines)

It's a great piece of software but it seems like the barrier is quite high to being efficient with it because it's unclear what questions you need to ask or where to look. Hopefully, you can help provide a better starting point for those stuck in the same way.

Thanks :)


回答1:


Access to hooks:

1.Start VisualSVN Server Manager

2.Open Properties for your repository

3.Select Hooks tab

4.Edit the needed hook

Hooks are convention rather than configuration based. You don't have to "hook" them up. Create a pre-commit hook and you have a hook running before commits. Create a post-commit hook and you have a hook that runs after a commit.

Here are the steps you can do in your post-commit script for what you need:

You get the repo path and revision commited as arguments to the post-commit hook, so use something like repo=%1 and rev=%2 to get these values.

One way to copy files after commit would be to have a working copy on your server, issue an svn update on this working copy after your commit in your post-commit hook and then copy over the files. You can selectively copy over files by getting the files that changed using svnlook changed. svnlook needs a revision and use the rev variable that you set earlier.

The script itself can be in any language.



来源:https://stackoverflow.com/questions/5763397/visual-svn-server-guide-on-pre-post-commit-hooks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!