Visual SVN Server:提交前/提交后挂钩指南
考虑到这里的评论,这可能是最好的维基百科: 分享常见/有用的 SVN 预提交挂钩
我正在使用 Visual Windows 7 计算机上的 SVN 2.1.7。我们有来自不同国家/地区的开发人员,我们可以通过运行更改的本地副本,然后通过 ftp 手动上传到正在处理的每个网站的服务器来管理代码更改。
这是一个非常耗时的过程,但比修复实时网站上的错误要少耗时,因此这是朝着正确方向迈出的一步。
在 Visual SVN 网站上,它提到了提交后和提交前挂钩,但未能显示可以访问的位置,即使它提到有一个 GUI。安装的版本中没有 GUI 的迹象,甚至没有选项,所以我首先无法找到访问它的位置。
假设它可以通过脚本来完成,我已经用谷歌搜索并来到SO寻找一些关于它可能在哪里以及如何完成的指导,但它似乎比我希望的要复杂得多。
有谁有关于如何在 Windows 上执行以下任务(未安装 perl)的经验或指导(包括示例脚本)?
a) 创建预提交命令/文件并将其执行附加到存储库/提交给它 b) 创建一个提交后命令/文件并将其执行附加到存储库/提交给它
,在我的例子中,这是一项特定任务: c) 如何在 PC 上安装本地 Visual SVN,以便将提交的文件发送到远程 CentOS 共享托管服务器(不是 VPS/Dedi 或云托管,并且 SVN 无法安装在这些计算机上)。
这是一个很棒的软件,但是似乎要高效地使用它的障碍相当高,因为不清楚您需要问什么问题或在哪里寻找。希望您可以帮助那些陷入同样困境的人提供一个更好的起点。
谢谢 :)
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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
访问钩子:
挂钩是约定而不是基于配置。您不必将它们“挂钩”。创建一个
pre-commit
挂钩,这样您就可以在提交之前运行一个挂钩。创建一个post-commit
挂钩,这样您就有了一个在提交后运行的挂钩。以下是您可以在提交后脚本中根据需要执行的步骤:
您将存储库路径和修订版作为参数提交给提交后挂钩,因此请使用类似
repo=%1
的内容和rev=%2
来获取这些值。提交后复制文件的一种方法是在您的服务器上有一个工作副本,在提交后在提交后挂钩中对此工作副本发出
svn update
,然后复制文件。您可以通过使用获取更改的文件来选择性地复制文件svnlook 已更改
。 svnlook 需要修订并使用您之前设置的rev
变量。脚本本身可以是任何语言。
Access to hooks:
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 apost-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
andrev=%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 usingsvnlook changed
. svnlook needs a revision and use therev
variable that you set earlier.The script itself can be in any language.
存储库挂钩 部分://www.visualsvn.com/server/documentation/" rel="nofollow noreferrer">VisualSVN 服务器 |文档页面。
通常,可以从 VisualSVN 中配置挂钩服务器管理器控制台或使用
Add-SvnRepositoryHook
PowerShell cmdlet。有一个钩子脚本列表(
.cmd
脚本):和一个简单的编辑器:
如果需要,您始终可以在您喜欢的文本编辑器(例如,此屏幕截图中的 Notepad++)中打开挂钩脚本,或使用可执行文件作为挂钩:
There is a dedicated Repository Hooks section on the VisualSVN Server | Documentation page.
Typically, the hooks can be configured from within the VisualSVN Server Manager console or using the
Add-SvnRepositoryHook
PowerShell cmdlet.There is a list of hook scripts (
.cmd
scripts):And a simple editor:
If needed, you can always open the hook script in your favorite text editor (e.g., Notepad++ as on this screenshot) or use an executable file as your hook: