如何从TFSGIT提取代码审查报告

时间:2019-02-23 01:26:16

标签: tfs pull-request tfs-code-review

我正在尝试从TFSGIT / VSTS中提取代码审查报告,但是我没有发现任何现成的东西。 诸如“ ReviewAssistant”之类的第3部分代码查看工具很好用,但未与Pull Request集成。它使代码审查脱钩以拉取请求。 我想从PullRequest代码注释中获取报告。

1 个答案:

答案 0 :(得分:0)

您可以使用Rest API从TFS中提取数据。

要获取PR代码注释,您可以使用Pull Request Threads - List

请求为:

https://{instance}/{collection}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/threads?api-version=4.1

在JSON响应中,您将在代码(行号)中获得注释和注释位置:

"comments": [
{
    "id": 1,
    "parentCommentId": 0,
    "author": {
    "displayName": "Shayki Abramczyk",
    "url": "https://spsprodweu3.vssps.visualstudio.com/Ac256a93d-7cea-4070-xxxxxxxxx/_apis/Identities/7a9a9b44-a2f1-6dfd-a7f6-xxxxxxxxxx",
    "_links": {
        "avatar": {
        "href": "https://dev.azure.com/xxxxxx/_apis/GraphProfile/MemberAvatars/msa.N2E5YTlxxxxxxxxxxxxxxx"
        }
    },
    "id": "7a9a9b44-a2f1-6dfd-a7f6-xxxxxxxxxx",
    "uniqueName": "xxxxxxxx",
    "imageUrl": "https://dev.azure.com/xxxxxxxx/_api/_common/identityImage?id=7a9a9b44-a2f1-6dfd-a7f6-xxxxxxxxxx",
    "descriptor": "msa.N2E5YTliNDQtYTJmMS03ZGZkLWE3Zjxxxxxxxxxxx"
    },
    "content": "test comment",
    "publishedDate": "2019-02-25T11:11:03.45Z",
    "lastUpdatedDate": "2019-02-25T11:11:03.45Z",
    "lastContentUpdatedDate": "2019-02-25T11:11:03.45Z",
    "commentType": "text",
    "usersLiked": [

    ]
}
],
"status": "active",
"threadContext": {
"filePath": "/SampleForVSTS/Program.cs",
"leftFileStart": {
    "line": 14,
    "offset": 1
},
"leftFileEnd": {
    "line": 14,
    "offset": 10
}
},

您可以看到文件test comment中第14行的注释SampleForVSTS/Program.cs

您可以使用任何语言编写简单的代码,以使用Rest API获取数据。

相关问题