我已经安装了 TotroiseSVN 并且我的大部分存储库都从 C:\subversion\ checkin 和 checkout ,还有一些从网络共享 checkin 和 checkout (我最初发布这个问题时忘记了这一点)。
这意味着我本身没有“颠覆”服务器。
我如何集成 TortoiseSVN 和 Fogbugz?
编辑:插入斜体
最佳答案
我一直在调查这个问题,并设法让它发挥作用。有几个小问题,但可以解决。
这个问题有 3 个不同的部分,如下所示:
第 1 部分的说明在另一个答案中,尽管它实际上超出了要求。关于钩子(Hook)的内容实际上是针对第 2 部分的,正如所指出的 - 它不能“开箱即用”
为了确认,我们正在考虑使用 TortoiseSVN 而没有 SVN 服务器(即基于文件的存储库)
我正在使用 UNC 路径访问存储库,但它也适用于本地驱动器或映射驱动器。
所有这些都适用于 TortoiseSVN v1.5.3 和 SVN Server v1.5.2(您需要安装 SVN Server,因为第 2 部分需要
svnlook.exe
,它在服务器包中。您实际上并未将其配置为用作 SVN Server)甚至可以只复制 svnlook.exe
从另一台计算机并将其放在您路径中的某个位置。第 1 部分 - TortoiseSVN
创建 TortoiseSVN 属性是获取 SVN 日志中的链接所需的全部内容。
以前的说明工作正常,为方便起见,我将在此处引用它们:
Configure the Properties
Right click on the root directory of the checked out project you want to work with.
Select "TortoiseSVN -> Properties"
Add five property value pairs by clicking "New..." and inserting the following in "Property Name" and "Property Value" respectively: (make sure you tick "Apply property recursively" for each one)
bugtraq:label BugzID: bugtraq:message BugzID: %BUGID% bugtraq:number true bugtraq:url http://[your fogbugz URL here]/default.asp?%BUGID% bugtraq:warnifnoissue false
Click "OK"
正如 Jeff 所说,您需要为每个工作副本执行此操作,因此请按照他的说明迁移属性。
就是这样。 TortoiseSVN 现在会在你提交时添加一个指向相应 FogBugz bugID 的链接。如果这就是你想要的,你可以停在这里。
第 2 部分 - FogBugz
为此,我们需要设置钩子(Hook)脚本。基本上每次提交后都会调用批处理文件,这反过来调用 VBS 脚本,该脚本将提交给 FogBugz。 VBS 脚本在这种情况下实际上可以正常工作,因此我们不需要修改它。
问题是批处理文件被编写为作为服务器钩子(Hook)工作,但我们需要一个客户端钩子(Hook)。
SVN 服务器使用以下参数调用 post-commit 钩子(Hook):
<repository-path> <revision>
TortoiseSVN 使用以下参数调用 post-commit 钩子(Hook):
<affected-files> <depth> <messagefile> <revision> <error> <working-copy-path>
所以这就是它不起作用的原因 - 参数错误。我们需要修改批处理文件,以便将正确的参数传递给 VBS 脚本。
您会注意到 TSVN 不传递存储库路径,这是一个问题,但它在以下情况下确实有效:
我会看看我是否能解决这个问题,如果我能解决,我会在这里发帖。
这是我修改后的批处理文件,它确实有效(请原谅过多的评论......)
您需要设置 Hook 和存储库目录以匹配您的设置。
rem @echo off
rem SubVersion -> FogBugz post-commit hook file
rem Put this into the Hooks directory in your subversion repository
rem along with the logBugDataSVN.vbs file
rem TSVN calls this with args <PATH> <DEPTH> <MESSAGEFILE> <REVISION> <ERROR> <CWD>
rem The ones we're interested in are <REVISION> and <CWD> which are %4 and %6
rem YOU NEED TO EDIT THE LINE WHICH SETS RepoRoot TO POINT AT THE DIRECTORY
rem THAT CONTAINS YOUR REPOSITORIES AND ALSO YOU MUST SET THE HOOKS DIRECTORY
setlocal
rem debugging
rem echo %1 %2 %3 %4 %5 %6 > c:\temp\test.txt
rem Set Hooks directory location (no trailing slash)
set HooksDir=\\myserver\svn\hooks
rem Set Repo Root location (ie. the directory containing all the repos)
rem (no trailing slash)
set RepoRoot=\\myserver\svn
rem Build full repo location
set Repo=%RepoRoot%\%~n6
rem debugging
rem echo %Repo% >> c:\temp\test.txt
rem Grab the last two digits of the revision number
rem and append them to the log of svn changes
rem to avoid simultaneous commit scenarios causing overwrites
set ChangeFileSuffix=%~4
set LogSvnChangeFile=svn%ChangeFileSuffix:~-2,2%.txt
set LogBugDataScript=logBugDataSVN.vbs
set ScriptCommand=cscript
rem Could remove the need for svnlook on the client since TSVN
rem provides as parameters the info we need to call the script.
rem However, it's in a slightly different format than the script is expecting
rem for parsing, therefore we would have to amend the script too, so I won't bother.
rem @echo on
svnlook changed -r %4 %Repo% > %temp%\%LogSvnChangeFile%
svnlook log -r %4 %Repo% | %ScriptCommand% %HooksDir%\%LogBugDataScript% %4 %temp%\%LogSvnChangeFile% %~n6
del %temp%\%LogSvnChangeFile%
endlocal
我将假设存储库位于
\\myserver\svn\
和工作副本都在`C:\Projects\\\myserver\svn\hooks\
.safe
在文件名的末尾。 post-commit-tsvn.bat
C:\Projects
(或任何您所有项目的根目录。)\\myserver\svn\hooks\post-commit-tsvn.bat
(这需要指向您在步骤 3 中放置 hooks 目录的任何位置)下次提交并输入 Bugid 时,它将提交给 FogBugz。链接不起作用,但至少有修订信息,您可以在 TortoiseSVN 中手动查找日志。
注意:您会注意到存储库根已硬编码到批处理文件中。因此,如果您从不具有相同根目录的存储库中 checkout (例如,一个在本地驱动器上,一个在网络上),那么您将需要在 TSVN 中的 Hook Scripts 下使用 2 个批处理文件和 2 个对应条目设置。这样做的方法是拥有 2 个单独的工作副本树 - 每个存储库根一个。
第 3 部分 - WebSVN
呃,我没有这样做:-)
从阅读 WebSVN 文档来看,WebSVN 似乎实际上并未与 SVN 服务器集成,它的行为与任何其他 SVN 客户端一样,但提供了一个 Web 界面。从理论上讲,它应该适用于基于文件的存储库。不过我没试过。
关于svn - 在没有 URL/Subversion 后端的情况下将 Fogbugz 与 TortoiseSVN 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3607/