Search code examples
azure-devopsazure-devops-rest-apiazure-repos

How to export Azure DevOps Services Branch Compare result?


How to export the results of Branch Compare in Azure Devops Services ? enter image description here

No Options to export is visible.

I have tried using the RestAPI of Diffs

The result is always link to closest common commit not a list of diffrent commits.

Couldn't find any way of using cli tools or sdk to access this feature. Please advise

If there is an option to access it programmatically or reproduce the same result's ?

UPDATE

There is no documented option - undocumented option was found see in answer.


Solution

  • We can get the REST API command by checking the network trace in Developer tools of Microsoft Edge. Please note that as the REST API is not documented, so it may change someday without notification.

    POST https://dev.azure.com/{organization}/_apis/Contribution/HierarchyQuery/project/{project}?api-version=5.0-preview
    

    Body:

    {
        "contributionIds": [
            "ms.vss-code-web.commits-data-provider"
        ],
        "dataProviderContext": {
            "properties": {
                "searchCriteria": {
                    "gitHistoryQueryArguments": {
                        "startFromVersion": {
                            "version": "branchname1" 
                        },
                        "notInVersion": {
                            "version": "branchname2"
                        },
                        "order": 0,
                        "path": "/",
                        "historyMode": 0,
                        "stopAtAdds": false,
                        "fromDate": "",
                        "toDate": "",
                        "author": "",
                        "committer": "",
                        "skip": 0,
                        "maxResultCount": 100
                    }
                },
                "repositoryId": "xxxxx-4931-4546-beb6-xxxxxxxxxxxx"
            }
        }
    }
    

    Result:

    enter image description here