I am working on patch release. I am getting change list from vsts using Microsoft VSTS API. I have 3 branches like A -> B -> C. A is base branch and b is created sub branch from A and c is created sub branch from B. So whatever changes I made in A and B that will be in C branch as well as C branch change. Now I have one pull request I'd which is targeted to the C branch. I am able to get all commits of C branch using pull request I'd. But I want to get parent class detail of C and then A. I tried but there is nothing I found.
Through Get Pull Request By Id rest api, you can get the repository id
, sourceRefName
, targetRefName
from the response body.
Then you can call Get Commits Batch rest api through the repository id
and sourceRefName
parameters to get all the commits of the parent branch.
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commitsbatch?api-version=5.1
Sample request body:
{
"itemVersion": {
"versionType": "branch",
"version": "dev"
}
}
Sample response:
{
"count": 32,
"value": [
{
"commitId": "bbcb0ee346961422c686fd4d3b2f63f74dffa1e3",
"author": {
"name": "hughl01",
"email": "xxx@hotmail.com",
"date": "2020-05-20T01:44:05Z"
},
"committer": {
"name": "hughl01",
"email": "xxx@hotmail.com",
"date": "2020-05-20T01:44:05Z"
},
"comment": "Deleted NEW",
"changeCounts": {
"Add": 0,
"Edit": 0,
"Delete": 2
},
"url": "https://dev.azure.com/xx/59b994e8-4a77-46a1-8b5d-xx/_apis/git/repositories/da09f0c6-1999-45b5-bb93-faa59f69fa24/commits/bbcb0ee346961422c686fd4d3b2f63f74dffxx",
"remoteUrl": "https://dev.azure.com/xx/xx/_git/forTest/commit/bbcb0ee346961422c686fd4d3b2f63f74dfxx"
},
...
}