我需要能够以编程方式查找 TFS 2010 变更集中单个文件的代码流失信息(添加、更改、删除的行)。我需要执行此操作的程序是桌面客户端应用程序。
有人知道怎么做吗?您有想要分享的示例代码吗?
这是一个起点:
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;
}
}
变更集具有以下内容:
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; }
变化有以下几点:
public ChangeType ChangeType { get; }
public Item Item { get; }
public ReadOnlyCollection<MergeSource> MergeSources { get; }
项目有以下内容:
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);
如果您愿意使用 Cube,您可以使用它来获取代码覆盖率。 http://blogs.msdn.com/b/jampick/archive/2010/07/06/tfs-2010-code-churn-report-getting-additional-detail.aspx