计算提交的代码更改行数? [英] Calculate lines of code change for a commit?

查看:33
本文介绍了计算提交的代码更改行数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法计算

Is there a way to calculate lines of code in a Pull Request API in Azure Devops for each file. I have gone through below two links and but was not of much help.

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

Lines of Code modified in each Commit in TFS rest api. How do i get?

Thank you.

解决方案

Steps:

a. Get the commit IDs for the specified pull request

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/commits?api-version=6.1-preview.1

b. Get commit path via the commit ID

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}/changes?api-version=5.0

c. Get parents commit ID via commit ID

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}?api-version=5.0

d. Get the result via below API and request body.

POST https://dev.azure.com/{Org name}/_apis/Contribution/HierarchyQuery/project/{Project name}?api-version=5.1-preview

Request Body:

{
  "contributionIds": [
    "ms.vss-code-web.file-diff-data-provider"
  ],
  "dataProviderContext": {
    "properties": {
      "repositoryId": "{Repo ID}",
      "diffParameters": {
        "includeCharDiffs": true,
        "modifiedPath": "{Commit path}",
        "modifiedVersion": "GC{Commit ID}",
        "originalPath": "{Commit path}",
        "originalVersion": "GC{parents commit ID}",
        "partialDiff": true
      }
    }
  }
}

Result:

这篇关于计算提交的代码更改行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆