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

我的梦境 提交于 2019-12-22 04:46:21

问题


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.


回答1:


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
    }

}


来源:https://stackoverflow.com/questions/24491196/how-to-get-history-of-checkins-changsets-for-specific-team-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!