开发者

How do I programatically lookup code churn info for individual files within a changeset in TFS 2010?

I need to be able to programatically lookup code churn info (lines added, changed, deleted) for individual files within a changeset in TFS 2010. The program that I need to do开发者_运维技巧 this is in is a desktop client application.

Anyone know how to do this? Do you have sample code you'd like to share?


Here is a starting point:

        TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("http://WhateverServerUrl");
        IBuildServer buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer));
        VersionControlServer VsServer = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
        IBuildDetail build = buildServer.GetAllBuildDetails(new Uri("http://WhateverBuildUrl"));

        List<IChangesetSummary> associatedChangesets = InformationNodeConverters.GetAssociatedChangesets(build);


        foreach (IChangesetSummary changeSetData in associatedChangesets)
        {
            Changeset changeSet = VsServer.GetChangeset(changeSetData.ChangesetId);
            foreach (Change change in changeSet.Changes)
            {
                bool a = change.Item.IsContentDestroyed;
                long b = change.Item.ContentLength;
            }
        } 

Changeset has the following:

    public Change[] Changes { get; set; }
    public int ChangesetId { get; set; }
    public CheckinNote CheckinNote { get; set; }
    public string Comment { get; set; }
    public string Committer { get; set; }
    public DateTime CreationDate { get; set; }
    public string Owner { get; set; }

Change has the following:

    public ChangeType ChangeType { get; }
    public Item Item { get; }
    public ReadOnlyCollection<MergeSource> MergeSources { get; }

Item has the following:

    public Uri ArtifactUri { get; }
    public Uri ArtifactUriLatestItemVersion { get; }
    public int ChangesetId { get; }
    public DateTime CheckinDate { get; }
    public static IComparer Comparer { get; }
    public long ContentLength { get; }
    public int DeletionId { get; }
    public int Encoding { get; }
    public byte[] HashValue { get; }
    public bool IsBranch { get; }
    public bool IsContentDestroyed { get; }
    public int ItemId { get; }
    public Stream DownloadFile();
    public void DownloadFile(string localFileName);


If you are willing to use the Cube you can use that to get your code coverage. http://blogs.msdn.com/b/jampick/archive/2010/07/06/tfs-2010-code-churn-report-getting-additional-detail.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜