Is there a way to get the amount of lines changed in a Pull Request via the Dev Ops Service REST API?

妖精的绣舞 提交于 2021-02-19 04:41:26

问题


I am currently doing my thesis and analyzing the behavior for code reviews. For this I want to know the size of the pull request that is reviewed. The rest of the information for example authors, reviewers, times etc. I got already by calling the rest API. However I cannot seem to find a way to get the amount of lines changed in each file, or a total number (which is also sufficient).

I have browsed the documentation and found some ways to get amount of files changed, see https://docs.microsoft.com/en-us/rest/api/azure/devops/git/commits/get%20commits?view=azure-devops-rest-5.1. However, I didn't found a way to get the amount of changed lines per file or a total amount.

So is there a way to get amount of lines changed in a Pull Request or between two commits?


回答1:


For your issue , I am afraid that there is currently no official released REST API to do that. A similar question has been answered in this case ,please refer to it for details, you can refer to these steps to achieve your requirements:

1.Get a list of commits to get a commit’s commit id.

2.Get a commit by commit id (steps 1) to get parents value and repository id (The value at the end of _links>Repository>href) (Using the URL of _links>Changes>href can get file path if you don’t know)

3.Get file diff by this POST request
https://dev.azure.com/{organization}/{project}/ _api/_versioncontrol/fileDiff?__v=5&diffParameters=[data 1]&repositoryId=[repository id]

You could also add your request for this feature on our UserVoice site, which is our main forum for product suggestions,our PM and product team will kindly review your suggestion.



来源:https://stackoverflow.com/questions/57569620/is-there-a-way-to-get-the-amount-of-lines-changed-in-a-pull-request-via-the-dev

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!