确定当前的变更集在哪些分支中

编程入门 行业动态 更新时间:2024-10-10 01:23:43
本文介绍了确定当前的变更集在哪些分支中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我需要以编程方式跟踪变更集:确定变更集当前位于哪个分支.

I need to programmatically track changesets: determine in which branch a changeset is currently located.

更新:假设我们有一个项目的三个分支:Dev、Test 和 Release.每当我们准备好使用一些变更集上线时,我们首先将它们合并到测试,然后在测试完成后立即发布.我需要知道给定变更集在此工作流程中的位置(仅在开发中 OR 在开发中 + 合并到测试中在开发中 + 合并到测试中 + 合并在发布中).

Update: Let's say we got three branches for a project: Dev, Test and Release. Whenever we're ready to go live with some changesets, we first merge them to Test, and then to Release as soon as the testing is done. I need to know where a given changeset is located in this workflow (only in Dev OR in Dev + merged in Test OR in Dev + merged in Test + merged in Release).

使用 Visual Studio 的跟踪"界面已经可以做到这一点,但我需要以编程方式执行此操作以对其进行更多自定义.我已经能够使用代码 此处提供,但我还没有找到一种方法来确定当前的变更集位于哪个分支.

It's already possible to do this using the Visual Studio "Tracking" interface, but I need to do it programmatically to get more customizations over it. I'm already able to get all the changesets for a specific work item using the code provided here, but I've yet to find a way to determine in which branches a changeset in present.

推荐答案

我刚刚制作了一个工具,它的功能完全相同.您需要的电话是 TrackMerges.好消息是您可以在一次调用中检查多个分支.这是一个代码片段:

I just made a tool which does the exact same thing. The call you need is TrackMerges. The good news is you can check multiple branches in one call. Here's a code snippet:

var tfsCollection = new TfsTeamProjectCollection(new Uri(server), new NetworkCredential(username, password, userDomain));
tfsCollection.EnsureAuthenticated();
VersionControlServer versionControlServer = tfsCollection.GetService<VersionControlServer>();

ExtendedMerge[] merges = versionControlServer.TrackMerges(
                                  new[] {changesetIdYouAreChecking}, 
                                  new ItemIdentifier("$/Proj/Dev"), 
                                  new [] {new ItemIdentifier("$/Proj/Test"), new ItemIdentifier("$/Proj/Release")}, 
                                  null);

foreach (ExtendedMerge extendedMerge in merges)
{
    Console.WriteLine("Branch --> " + extendedMerge.TargetItem.Item);
    Console.WriteLine("Changeset --> " + extendedMerge.TargetChangeset.ChangesetId);
}

如果合并变量不包含您要查找的分支,则它尚未合并.

If the merges variable does not contain the branch you are looking for, then it hasn't been merged.

这篇关于确定当前的变更集在哪些分支中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 18:24:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1398105.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分支

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!