查找与工作项关联的变更或具有特定评论TFS阿比 [英] Finding changesets associated with the work item or having specific comment TFS Api

查看:306
本文介绍了查找与工作项关联的变更或具有特定评论TFS阿比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到使用Microsoft.TeamFoundation.WorkItemTracking.Client工作项目相关的所有的变更。使用查询我能得到有关问题的工作项目的信息,但我找不到我取回对象的任何变更信息。除此之外还有一些未链接到具体的工作项目,但容易被识别的注释变更。是否有一个快速的方法来找到这些使用TFS API?

I'm trying to find all changesets associated with the work item using Microsoft.TeamFoundation.WorkItemTracking.Client. Using query I was able to get the information about the work items in question, however I cannot find any changeset information on the object I'm getting back. In addition to that there are some changesets that are not linked to specific work item but easy identifiable by the comment. Is there a quick way to find these using tfs api?

编辑:这不是的如何使用TFS的API? b / C在这个问题的人一个修改ID相关的工作项目有变更,并想找到相关的工作项目。在我来说,我有一个工作项目,我想找到具体的工作项目相关的所有的变更。此外,我需要找到具有在注释特定字符串的所有的变更。

this is not a duplicate of How to get work items associated with a changeset id using tfs api? b/c in that question person has a changeset and would like to find associated work items. In my case I have a work items and I would like to find all changesets associated with the specific work items. In addition to that I need to find all changesets that have specific string in the comment.

推荐答案

经过谷歌搜索的主题和探索TFS API这里是我结束了:

After more googling on the subject and exploring tfs API here is what I ended up with:

如果你变更集链接到工作项(不是真的我的情况,但是这是我最初问):

If all you changesets are linked to the work items (not really my case but this is what I originally was asking about):

// based on https://etoptanci.wordpress.com/2011/05/04/seeing-all-code-changes-for-a-work-item/
private static void GetChangesForWorkItem()
{
    var configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(@"http://myserver:8080/tfs"));
    var tpcService = configurationServer.GetService<ITeamProjectCollectionService>();
    var collectionNodes = configurationServer.CatalogNode.QueryChildren(
           new[] { CatalogResourceTypes.ProjectCollection },
           false, CatalogQueryOptions.None);

    var collectionNode = collectionNodes.First(x => x.Resource.DisplayName == "<collection name>");

    // Use the InstanceId property to get the team project collection
    Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
    TfsTeamProjectCollection collection = configurationServer.GetTeamProjectCollection(collectionId);
    var vcs = collection.GetService<VersionControlServer>();
    var store = new WorkItemStore(collection);
    var workItems = new List<WorkItem>()
    {
        store.GetWorkItem(1123),
        store.GetWorkItem(1145),
    };

    var associatedChangesets = new List<Changeset>();

    foreach (var workItem in workItems)
    {
        foreach (var link in workItem.Links) 
        {
            if((link==null) || !(link is ExternalLink))
            continue;

            string externalLink = ((ExternalLink)link).LinkedArtifactUri;
            var artifact =LinkingUtilities.DecodeUri(externalLink);

            if (artifact.ArtifactType == "Changeset")
                associatedChangesets.Add(vcs.ArtifactProvider.GetChangeset(new Uri(externalLink)));
        }
    }

    Console.WriteLine(associatedChangesets.Select(x=>x.ChangesetId).OrderBy(x => x));
}

如果您需要通过评论来获得,以及那么你门的所有变更集日期范围,然后通过Changeset.Comment它是一个字符串滤除

If you need to get by comment as well then you gate all changesets for the daterange and then filter out by Changeset.Comment which is a string.

这篇关于查找与工作项关联的变更或具有特定评论TFS阿比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆