问题描述
限时送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:关键词]
发布评论