Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get history of checkins/changsets for specific Team Project?

Tags:

c#

api

tfs

tfs-sdk

I'm using the TFS Client API to try and query a TFS 2010 instance. I need to be able to do the following

  • For a specified team project, say 'Project A'
  • Get a list of the history of recent check-ins made to this project (say the last 50, or the list for the last day)

Then be able to iterate through this list and get some metadata for the items (file and folder names ideally)

I think I need to use the QueryXXX methods on the VersionControlServer class, but cannot find any helpful or clear examples on how to use this.

I have seen there is GetLastestChangesetId method, but this doesn't look like it can be scoped to a specific project or directory.

like image 373
AbAkt Avatar asked Jun 30 '14 13:06

AbAkt


1 Answers

This is pretty straightforward:

var tfsUrl = "http://myTfsServer:8080/tfs/defaultcollection";
var sourceControlRootPath = "$/MyTeamProject";
var tfsConnection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsUrl));
var vcs = tfsConnection.GetService<VersionControlServer>();

var changeSets = vcs.QueryHistory(sourceControlRootPath, RecursionType.Full);

foreach (var c in changeSets)
{
    var changeSet = vcs.GetChangeset(c.ChangesetId);
    foreach (var change in changeSet.Changes) 
    {
       // All sorts of juicy data in here
    }

}
like image 78
Daniel Mann Avatar answered Nov 20 '22 18:11

Daniel Mann