【问题标题】:Is there a way to get the amount of lines changed in a Pull Request via the Dev Ops Service REST API?有没有办法通过 Dev Ops 服务 REST API 获取拉取请求中更改的行数?
【发布时间】:2020-06-26 11:59:31
【问题描述】:

我目前正在撰写论文并分析代码审查的行为。为此,我想知道所审查的拉取请求的大小。其余的信息,例如作者、审阅者、时间等。我已经通过调用其余 API 获得。但是,我似乎无法找到一种方法来获取每个文件中更改的行数或总数(这也足够了)。

我浏览了文档并找到了一些获取更改文件数量的方法,请参阅https://docs.microsoft.com/en-us/rest/api/azure/devops/git/commits/get%20commits?view=azure-devops-rest-5.1。但是,我没有找到获取每个文件更改的行数或总数的方法。

那么有没有办法在拉取请求中或两次提交之间获取更改的行数?

【问题讨论】:

    标签: azure-devops azure-devops-rest-api devops-services


    【解决方案1】:

    对于你的问题,恐怕目前还没有官方发布的 REST API 可以做到这一点。这个case已经回答了类似的问题,详情请参考,您可以参考以下步骤来实现您的要求:

    1.Get a list of commits 获取提交的提交 ID。

    2.Get a commit by commit id (steps 1) to get parents value and repository id (The value at end of _links>Repository>href) (使用_links>Changes>href的URL可以得到文件路径 if你不知道)

    3.通过这个 POST 请求获取文件差异
    https://dev.azure.com/{organization}/{project}/ _api/_versioncontrol/fileDiff?__v=5&diffParameters=[data 1]&repositoryId=[repository id]

    您也可以在我们的UserVoice site 上添加您对该功能的请求,这是我们产品建议的主要论坛,我们的产品经理和产品团队将很乐意审核您的建议。

    【讨论】:

      猜你喜欢
      • 2021-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-04
      • 1970-01-01
      相关资源
      最近更新 更多