0

I am pulling a file from on premise TFS source control using the Rest API. I can't find on premise specific documentation, but it seems to be very close to version 4.1 of the Azure Get Item call. According to this documentaiton, it should return a TfvcItem object which has a lot of metadata including the version. However, when I make the call it only returns the file contents (the content field of the documentation's TfvcItem).

How do I get the current version of the file?
I need the version when I check itin with create changeset. I don't need it for any other reason, so if you know another way to check in an edited file that would help.

4

1 回答 1

1

一些相关的 REST API 没有记录,而不是使用 Get Item API。对于这些 REST API,我们可以使用 Fiddler 等工具或直接在 Chrome 中按F12-network来跟踪它们。

您应该使用以下 API 来获取文件的最新变更集版本:

post   https://dev.azure.com/{organizationname}/{Projectname}/_api/_versioncontrol/history?__v=5 

对于身体:

{"repositoryId":"","searchCriteria":"{\"itemPath\":\"$/MyFirstProject/Main/1.txt\",\"itemVersion\":\"T\",\"top\":50}"}

itemPath是文件的服务器路径。

从响应中,您将获得版本信息,例如"version": "139", 而不是文件内容。

不确定您的 TFS 详细版本,我以 Azure DevOps Service 为例。不同的 TFS 版本可能存在一些差异。您可以自己跟踪详细 API。

更多详细信息请看这个问题:VSTS Release API Documentation

于 2020-05-05T09:40:21.493 回答