Azure Git Get commit changes API return parent folder if file inside is modified

3Dcat 21 Reputation points
2022-01-24T15:12:22.137+00:00

Azure Git API to get commit changes (https://learn.microsoft.com/en-us/rest/api/azure/devops/git/commits/get-changes?view=azure-devops-rest-6.0), lists parent folders as well with changeType as "edit" even when only the file within the folder is modified.
In Azure Git UI it says only 1 changed file

Please suggest if there are any flags that can be used to get only the file that was changed and not the parent folders

Thanks in advance

Community Center | Not monitored
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 60,161 Reputation points
    2022-01-24T16:01:26.923+00:00

    For Azure Git it can return tree when referencing collections of items like files, tags, etc. There is no parameter to filter out these as Git doesn't actually understand folders, it is completely file based. Hence you cannot have an empty folder.

    To "filter out" trees you need to post process the JSON and remove any item that has a gitObjectType of tree. Note that it might return other types as well so alternatively you could simply look for blob types instead. Refer to the documentation on the object type for more information. Here's a link to a non-Azure DevOps overview of some of these object types.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.