3

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 :)

4

1 回答 1

2

访问钩子:

1.启动VisualSVN服务器管理器

2.打开存储库的属性

3.选择挂钩选项卡

4.编辑需要的钩子

钩子是约定而不是基于配置的。您不必“挂钩”它们。创建一个pre-commit钩子,你有一个在提交之前运行的钩子。创建一个post-commit钩子,你就有一个在提交后运行的钩子。

以下是您可以在提交后脚本中根据需要执行的步骤:

您将 repo 路径和修订作为参数提交给 post-commit 钩子,因此使用类似repo=%1andrev=%2来获取这些值。

提交后复制文件的一种方法是在您的服务器上拥有一个工作副本,svn update在您的提交后挂钩中在此工作副本上发出一个,然后复制文件。您可以通过获取使用更改的文件来选择性地复制文件svnlook changed。svnlook 需要修改并使用rev您之前设置的变量。

脚本本身可以是任何语言。

于 2011-04-23T09:47:40.563 回答