简体   繁体   中英

Get TFS information for locally mapped file or directory via WebApi

I want to use the Teamfoundation.SourceControl.WebApi to check for updates or local changes against our TFS Source Control.

I can gather information about changesets from an item which is committed TFS but I am not able to gather this information based on a local file path inside my mapped workspace.

Is it somehow possible without using the ExtendedClient ?

I want something like this:

TfvcChangesetSearchCriteria tcsc = new TfvcChangesetSearchCriteria();
tcsc.ItemPath = @"c:\source\mappedtfs\MYPROJECT\src\MainWindow.cs";/*<--- localPath would be nice here*/                
List<TfvcChangesetRef> changerefs = tfvcHttpClient.GetChangesetsAsync("MYPROJECT", null, null, null, null, tcsc).Result;

Microsoft.Teamfoundation.SourceControl.WebApi is a webapi which does not interact with local workspaces and files. If you want to get changesets with local items' path, use Microsoft.TeamFoundation.VersionControl.Client in the Client Library.

using Microsoft.TeamFoundation.Client;
using System;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Microsoft.TeamFoundation.VersionControl.Client;
using System.Collections.Generic;

namespace ConsoleX
{
    class Program
    {
        static void Main(string[] args)
        {
            Uri url = new Uri("https://tfsuri");
            TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(url);
            VersionControlServer vcs = ttpc.GetService<VersionControlServer>();
            IEnumerable<Changeset> cses = vcs.QueryHistory("Path here could be local path or server path", RecursionType.Full);
            foreach (Changeset cs in cses)
            {
                Console.WriteLine(cs.ChangesetId);
                Console.WriteLine(cs.Comment);
            }
            Console.ReadLine();
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM