TFS 中的自定义签入策略?
我们的项目中有一些 xml 文件,每当我们将这些 xml 文件签入 TFS 时,我们都会在签入之前确保已将这些 xml 文件添加到专有应用程序中。
现在,新员工经常忘记在签入之前将文件添加到专有应用程序中,而且这种情况越来越严重......
我们想要一个确认对话框(提醒),询问开发人员是否已将 xml 文件添加到应用程序中。如果是,则签入,否则保持签出...
请建议此类事情是否可能,并且任何相关代码或链接将不胜感激。
We have some xml files in the our project and whenever we check-in these xml files into TFS, We have make sure before checking-in that we have added those xml files to proprietary application.
Now the new employees more often forget to add files into proprietary application before check-in and this is getting serious...
We want kinda confirmation dialog (a reminder) asking the developers if they have added the xml files into the app. If yes then check-in otherwise keep it checkedout...
Please suggest if such thing is possible and any relevant code or links will be really appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在自定义签入策略中引发 UI 是不合适的 - 签入策略的生命周期非常短,并且它们将被频繁评估,并且不一定在 UI 上下文或 UI 线程上。
您能否以编程方式确定是否签入了适当的 XML 文件?如果是这样,您可以创建一个自定义签入策略,如果未挂起添加 XML 文件,该策略就会失败。
门控签入可能是此问题的最佳解决方案:如果这些 XML 文件不存在,构建会失败吗?或者如果这些文件丢失,单元测试会失败吗?如果是这样,那么这是门控签到的完美候选者,这将阻止这些签到的发生。
It's not appropriate to raise UI in a custom check-in policy - the lifecycle of a check-in policy is very short, and they will be evaluated frequently and not necessarily in a UI context or on the UI thread.
Can you determine programmatically whether the appropriate XML files are being checked in? If so, you could create a custom check-in policy that fails if the XML files are not pended for add.
Gated Check-in may be the best solution to this problem: does the build fail if these XML files do not exist - or would unit tests fail if these files are missing? If so, this is a perfect candidate for Gated Check-in, which will prevent these check-ins from occurring.
我将创建一个自定义构建模板来检查这些 xml 文件。让它成为一个封闭的签入,你就得到了你的解决方案。
I would create a custom build template that checks for these xml files. Make it a gated check-in and you've got your solution.
Evaluate
方法应该是快速的并且不应该显示 UI,但是当用户与称为Activate
的策略交互时,策略上会触发一个事件,这是这是展示 UI 并与策略沟通的好时机。你可以这样做:我还没有测试过这个确切的代码,它可能需要一些调整,但这是一般要做的事情。现在,它会在签入的文件发生更改时触发,但您也可以订阅任何其他事件(工作项更改)或在每次调用 Evaluate 时触发您自己的项目评估。
或者您可以在每个签入周期触发一次确认。这一切都取决于你。您甚至可以执行“单击关闭”并完全跳过
Messagebox
。只需设置_userConfirmed=true
并触发PolicyStateChanged
事件。The
Evaluate
method is supposed to be quick and should not show UI, but there is an event on the policy that triggers when the user interacts with the policy calledActivate
, this is a good moment to show UI and communicate with the policy. You could do something like this:I haven't tested this exact code yet, it might need some tweaking, but this is the general thing to do. Right now it triggers on a change in the files being checked in, but you can subscribe to any of the other events as well (work item changes) or trigger your own evaluation of the project each time Evaluate is called.
Or you can just trigger the confirm once per checkin cycle. it's all up to you. You could even do a "Click to Dismiss" and skip the
Messagebox
altogether. Just set_userConfirmed=true
and fire thePolicyStateChanged
event.