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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With