TFS 2010 以编程方式确定项目分支
如何以编程方式确定该文件属于哪个分支?我花了 3 个小时试图解决这个问题,但没有结果。我找到了这个主题,但这不是我想要的: 如何以编程方式获取有关 TFS 中分支的信息?
How can I determine programatically which branch this file belongs to? I've spent 3 hours trying to figure this out with no results. I found this topic but it's not what I want: How to programmatically get information about branches in TFS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有一个非常相似的问题。我找到了一个解决方案,这里是代码:
我希望这可以帮助解决这个问题的人,我认为操作员已经解决了它(自从他问这个问题以来已经有一段时间了)。
I had a very similar problem. I found a solution to it, here is the code:
I hope this helps someone with this problem, I think the op has already solved it (it's been a while since he asked the question).
我发现获取特定文件的分支信息的唯一方法是使用 VersionControlServer.QueryBranchObjects 查询文件夹结构中的每个可能的分支,一直到根。
但是,您可以做出一些假设并相当有效地完成 - 因为一个分支不能位于 tfs 2010 中的另一个分支中。找到正在签入的所有文件的路径的公共子集并测试这些文件,如果没有一个是分支,那么它们就不是属于同一分支。
The only way I've found to get branch info for a specific file is to use VersionControlServer.QueryBranchObjects to query each possible branch in a folder structure all the way up to the root.
However you can make a few assumptions and do it fairly efficiently - as a branch cannot be in another branch in tfs 2010. Find the common subset of paths of all files being checked in and test those, if none are branches then they don't belong to same branch.