Reputation: 1542
It is very straightforward to get all changesets, specific changesets, or even look a specific version of a file (given a changeset id) using not only the TFS API but the .NET client libraries.
However, what I can't seem to figure out is given the name/path of a file, and a specific branch, is how to retrieve the changeset history for that file.
I've tried using both the TfvcHttpClient as well as the raw TFS API (building my http GET request by hand) and I cannot seem to find a way to make this happen.
This is very similar to viewing a file's history in Visual Studio 2017:
I'm literally looking for a way via the TFS API to give me this information back.
Is this possible?
Thanks!
Upvotes: 2
Views: 2298
Reputation: 173
You can also do this with TfvcHttpClientBase.GetChangesetsAsync and the ItemPath property of TfvcChangesetSearchCriteria
Here's an example in Powershell
$tfvcSearchCriteria = [Microsoft.TeamFoundation.SourceControl.WebApi.TfvcChangesetSearchCriteria]::new()
$tfvcSearchCriteria.FollowRenames = $true
$tfvcSearchCriteria.ItemPath = $ItemPath
$result = $TfvcHttpClient.GetChangesetsAsync($null, $null, $null, $null, $tfvcSearchCriteria).Result
Upvotes: 0
Reputation:
Depending on what API version you are using, here is the reference information for changesets.
the core url is: GET {tfsurl}/{organization}/{project}/_apis/tfvc/changesets?api-version=5.0
Upvotes: 0
Reputation: 4034
Rest API request:
{tfsurl}/{project}/_api/_versioncontrol/history"
In the request body:
{repositoryId: "", searchCriteria: "{"itemPath":"$/YourProject/YourFile","itemVersion":"T","top":50}"}
It will return the history for the itemPath
from your body.
Sadly I struggle to find any documentation on this :/
Upvotes: 2
Reputation: 16133
I can not find any history request for tfvc here - Rest Api TFVC Version Control.
As workaround you can try to run tf.exe history and parse the output.
Upvotes: 0