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.
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.
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.
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 .
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;
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
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With