gpt4 book ai didi

c# - 如何获取文件添加到 TFS 的日期

转载 作者:太空宇宙 更新时间:2023-11-03 23:30:36 24 4
gpt4 key购买 nike

对于特定的分支,我想生成一个文件名列表以及它们最初添加到 TFS 的日期。我真的不介意我用什么方法来获取它,但命令行或 C# 解决方案会很棒。我没有包含任何我尝试过的东西,因为我真的不知道从哪里开始!

我试图得到这样的结果:

Date added     File name
========================
10/02/2015 File1.txt
16/05/2015 File2.txt
19/08/2014 File3.txt

最佳答案

好的,这可以做到,但我不知道这会执行得如何,这可能取决于您的代码库的大小。

在 TFS API 上使用 VersionControlServer 我正在获取所有项目,然后为每个项目查询历史记录以获取第一个变更集,然后获取详细信息:

    void Main()
{
const String CollectionAddress = "http://tfs:8080/tfs/DefaultCollection";

using (var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(CollectionAddress)))
{
tfs.EnsureAuthenticated();
var server = tfs.GetService<VersionControlServer>();

server.GetItems(
path: "$/Code/",
version: VersionSpec.Latest,
recursion: RecursionType.Full,
deletedState: DeletedState.NonDeleted,
itemType: ItemType.File)
.Items
.Select(
item =>
server
.GetBranchHistory(
itemSpecs: new[] { new ItemSpec(item.ServerItem, RecursionType.None), },
version: VersionSpec.Latest)
.Single()
.Select(
a =>
new
{
a.Relative.BranchToItem.ChangesetId,
a.Relative.BranchToItem.CheckinDate,
a.Relative.BranchToItem.ServerItem,
})
.Single())
.Dump(5);
}
}

您可以从 here 下载一个有效的 Linqpad 脚本- 针对 VS2013 对象模型。

关于c# - 如何获取文件添加到 TFS 的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32377778/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com