使用TFS API,是否可以获取最后签入文件的人

发布于 2024-12-18 13:05:51 字数 109 浏览 3 评论 0原文

这是使用 TFS2010 API。

给定文件名,我需要获取详细信息,例如文件的文件夹路径、上次签入的人、上次签入的日期时间。

有 API/WIQL 可以帮助解决这个问题吗?

this is using TFS2010 API.

Given a file name, I need to get the details like folder path of the file, who checked in the last, datetime of last checkin.

Is there an API/WIQL that can help solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

向地狱狂奔 2024-12-25 13:05:51

对于第一部分,从文件名检索该文件的 SourceControl 路径,除了 this:

tf dir $/*file.cs /recursive /server:http://TFSServer:8080

一旦您获得了 SourceControl 路径文件,您可以尝试以下操作:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;

namespace ChangesetDetails
{
    class Program
    {
        static void Main(string[] args)
        {
            TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://TFSServer:8080"));
            VersionControlServer vcs = (VersionControlServer) tpc.GetService(typeof (VersionControlServer));

            IEnumerable results = vcs.QueryHistory(@"$/../file.cs", 
                                                    VersionSpec.Latest, 0, RecursionType.Full, null, null, null, int.MaxValue, true, true);
            List<Changeset> changesets = results.Cast<Changeset>().ToList();
            Changeset latestChangeset = changesets.ElementAt(0);
        }
    }
}

这将获取 $/../file.cs 的最新变更集,然后可以显示您想要的属性:

string lastCommiter = latestChangeset.Owner;
DateTime dateCommited =  latestChangeset.CreationDate;

For the first part, retrieving from a filename the SourceControl path(s) to this file, I couldn't find anything other than this:

tf dir $/*file.cs /recursive /server:http://TFSServer:8080

Once you have the SourceControl path to the file, you can try this:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;

namespace ChangesetDetails
{
    class Program
    {
        static void Main(string[] args)
        {
            TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://TFSServer:8080"));
            VersionControlServer vcs = (VersionControlServer) tpc.GetService(typeof (VersionControlServer));

            IEnumerable results = vcs.QueryHistory(@"$/../file.cs", 
                                                    VersionSpec.Latest, 0, RecursionType.Full, null, null, null, int.MaxValue, true, true);
            List<Changeset> changesets = results.Cast<Changeset>().ToList();
            Changeset latestChangeset = changesets.ElementAt(0);
        }
    }
}

This shall obtain the latest Changeset of $/../file.cs, which then can reveal the properties you 're after:

string lastCommiter = latestChangeset.Owner;
DateTime dateCommited =  latestChangeset.CreationDate;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文