命令使用VS命令promot获取所有分支和最新历史的列表 [英] command to get list of all branches and latest history using VS command promot

查看:207
本文介绍了命令使用VS命令promot获取所有分支和最新历史的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好


您好



我需要一个命令来使用TFS命令提示符知道分支名称,最新histort,最后一个用户名。我使用了以下查询


tf history * / recursive


它工作正常,但没有给出分支名称而是提供我所需要的更改表详细信息。我期待分支名称。请帮忙。


解决方案

Hi Mohit818,


您可以使用TFS API获取所有分支和分支历史记录:


  1. 创建控制台应用程序
  2. 安装< a href ="https://www.nuget.org/packages/Microsoft.TeamFoundationServer.ExtendedClient/">
    Microsoft Team Foundation Server扩展客户端软件包

简单代码:

 NetworkCredential cred = new NetworkCredential(" [username]"," [Password]",[domain] "); 
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(" [collection url]"),cred);
tpc.EnsureAuthenticated();

VersionControlServer versionControl = tpc.GetService< VersionControlServer>();
ItemSet allItems = versionControl.GetItems(new ItemSpec("


/ ScrumStarain",RecursionType.OneLevel,(int)DeletedState.NonDeleted),VersionSpec.Latest,DeletedState.NonDeleted ,ItemType.Folder,GetItemsOptions.IncludeBranchInfo);
foreach(allItems.Items中的var项)
{
if(item.IsBranch)
{

var branchHistory = versionControl.GetBranchHistory(new ItemSpec [] {new ItemSpec(item.ServerItem,RecursionType.OneLevel)},VersionSpec.Latest);
}
}

问候


Starain


Hi

Hi

I need a command to know branch name,latest histort, last user name using TFS command prompt. I used the below query

tf history * /recursive

it working fine but not giving branch name instead giving changesheet details which I do nt needed. I am expecting branch name. pls help.

解决方案

Hi Mohit818,

You can get all branches and branch histories by using TFS API:

  1. Create a console application
  2. Install Microsoft Team Foundation Server Extended Client package

Simple code:

 NetworkCredential cred = new NetworkCredential("[username]", "[Password]", "[domain]");
            TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("[collection url]"), cred);
            tpc.EnsureAuthenticated();

VersionControlServer versionControl = tpc.GetService<VersionControlServer>();
            ItemSet allItems = versionControl.GetItems(new ItemSpec("


/ScrumStarain", RecursionType.OneLevel,(int)DeletedState.NonDeleted),VersionSpec.Latest,DeletedState.NonDeleted,ItemType.Folder,GetItemsOptions.IncludeBranchInfo); foreach(var item in allItems.Items) { if(item.IsBranch) { var branchHistory= versionControl.GetBranchHistory(new ItemSpec[] { new ItemSpec(item.ServerItem, RecursionType.OneLevel) }, VersionSpec.Latest); } }

Regards

Starain


这篇关于命令使用VS命令promot获取所有分支和最新历史的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆