Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the latest check in number (latest changeset id)

Tags:

c#

tfs-sdk

Is there a way to get programmatically latest changeset version in general.

It's fairly easy to get changeset id for certain file :

var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("https://my.tfs.com/DefaultCollection"));
        tfs.EnsureAuthenticated();
        var vcs = tfs.GetService<VersionControlServer>();

and then call GetItems or QueryHistory, but i would like to know what was the last checkin number.

like image 251
Jacob Avatar asked Feb 10 '12 14:02

Jacob


People also ask

How do I find the latest changeset in TFS?

Take searching for a changeset in Visual Studio's TFS Source Explorer. Luckily if super easy to do! When you're in the Source Explorer, simply press Ctrl + G and the Find ChangeSet dialog will appear. From here you can type the changeset number and press OK.

How do I find my TFS changeset number?

Find a changeset by IDIn Source Control Explorer, press Ctrl + G. The Go to Changeset dialog box appears. Type the number of the changeset and choose OK. If you don't know the number, choose Find.

How do I check my TFS history?

Right-Click If you have the Source Control Explorer or File List open, right-click the file you want to view and select Source Control > View History. Local Toolbar In the File List, select the file(s) you want to view. In the local toolbar of the File List, click , then select View History .


2 Answers

You can do it like this:

var latestChangesetId =
    vcs.QueryHistory(
        "$/",
        VersionSpec.Latest,
        0,
        RecursionType.Full,
        String.Empty,
        VersionSpec.Latest,
        VersionSpec.Latest,
        1,
        false,
        true)
        .Cast<Changeset>()
        .Single()
        .ChangesetId;
like image 71
DaveShaw Avatar answered Oct 30 '22 04:10

DaveShaw


Use VersionControlServer.GetLatestChangesetId to get the latest changeset id, as mentioned by user tbaskan in the comments.

(In the TFS Java SDK it's VersionControlClient.getLatestChangesetId)

like image 34
kapex Avatar answered Oct 30 '22 04:10

kapex