Azure DevOps API TFS: How to get a file history if it was renamed and/or branched?

Viewed 181

Is this possible somehow to get a file history (all related changesets) with API request if the file was branched or/and renamed?

For example, if I need to find a history of the object in Azure DevOps UI I can search this object in the project, in a certain path like this:

enter image description here

And if I need to find the first appearance of the object in a repository, I can get it by expanding a "branch and rename" history

full history of the object

There is a need to get this information via API requests.

I had tried to find some API requests which can do it, but found only the requests which can return only the changesets which are on the first picture, where the object has the same name and is located under the path defined in the search parameter - there is no information about renaming/branching operations.

  1. GET https://dev.azure.com/Contoso/_apis/tfvc/changesets?api-version=6.0&searchCriteria.itemPath=$/Contoso/Trunk/Main/Metadata/Application_Ext_Contoso/Application_Ext_Contoso/AxSecurityPrivilege/Entity.xml

returns only 3 changesets - 2162, 2161, 391

  1. POST https://dev.azure.com/Contoso/Contoso/_api/_versioncontrol/history?api-version=6.0

With the body request

{
    "repositoryId":"",
    "searchCriteria":"{\"itemPaths\":[\"$/Contoso/Trunk/Main/Metadata/Application_Ext_Contoso/Application_Ext_Contoso/AxSecurityPrivilege/Entity.xml\" ], \"followRenames\" : true ,\"top\":50}",
    "includeSourceRename" : true
}

Also returns only 3 changesets, it only finds a specific item path, I tried to experiment with includeSourceRename and followRenames , but they do not work as I expected.

  1. POST https://almsearch.dev.azure.com/Contoso/Contoso/_apis/search/codesearchresults?api-version=6.0-preview.1

with the body

{
  "searchText": "Entity.xml",
  "$skip": 0,
  "$top": 25,
  "filters": {
    "Project": [
      "Contoso"
    ],
    "Repository": [
      "$/Contoso"
    ],
    "Path": [
        "$/Contoso/"
    ]
  },
  "$orderBy": [
    {
      "field": "filename",
      "sortOrder": "ASC"
    }
  ],
  "includeFacets": true
}

Also returns information only about 3 changesets.

Are there some approaches to get this information from the API request?

0 Answers
Related