我们被要求生成有关我们一直在进行的代码审核的指标。在Stash / Git中是否有办法提取在回购中执行的历史拉取请求?特别是,以下内容将非常有用:
答案 0 :(得分:3)
正如Robbie Averill已经建议的那样,您可以使用Stash REST APIs,更具体地说Stash Core REST API,其中为核心存储功能(如服务器管理)提供REST资源,项目,存储库,拉取请求和用户管理:
# pick ...
/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests会针对有问题的回购提供paged个公开拉取请求列表。回复包含您要查找的大部分信息,尤其是拉取请求日期,GET
,author
甚至reviewers
:
participants
缺少的是确切的批准日期,但如果您恰好使用Checks for merging pull requests并且至少需要一次批准,则可以从拉取请求{
"size": 1,
"limit": 25,
"isLastPage": true,
"values": [
{
"id": 101,
"version": 1,
"title": "Talking Nerdy",
"description": "It’s a kludge, but put the tuple from the database in the cache.",
"state": "OPEN",
"open": true,
"closed": false,
"createdDate": 1359075920,
"updatedDate": 1359085920,
"fromRef": {
"id": "refs/heads/feature-ABC-123",
"repository": {
"slug": "my-repo",
"name": null,
"project": {
"key": "PRJ"
}
}
},
"toRef": {
"id": "refs/heads/master",
"repository": {
"slug": "my-repo",
"name": null,
"project": {
"key": "PRJ"
}
}
},
"locked": false,
"author": {
"user": {
"name": "tom",
"emailAddress": "tom@example.com",
"id": 115026,
"displayName": "Tom",
"active": true,
"slug": "tom",
"type": "NORMAL"
},
"role": "AUTHOR",
"approved": true
},
"reviewers": [
{
"user": {
"name": "jcitizen",
"emailAddress": "jane@example.com",
"id": 101,
"displayName": "Jane Citizen",
"active": true,
"slug": "jcitizen",
"type": "NORMAL"
},
"role": "REVIEWER",
"approved": true
}
],
"participants": [
{
"user": {
"name": "dick",
"emailAddress": "dick@example.com",
"id": 3083181,
"displayName": "Dick",
"active": true,
"slug": "dick",
"type": "NORMAL"
},
"role": "PARTICIPANT",
"approved": false
},
{
"user": {
"name": "harry",
"emailAddress": "harry@example.com",
"id": 99049120,
"displayName": "Harry",
"active": true,
"slug": "harry",
"type": "NORMAL"
},
"role": "PARTICIPANT",
"approved": true
}
],
"link": {
"url": "http://link/to/pullrequest",
"rel": "self"
},
"links": {
"self": [
{
"href": "http://link/to/pullrequest"
}
]
}
}
],
"start": 0
}
日期开始估算。
closed
应该会为每位评论者返回这些详细信息,但不幸的是,GET
仅记录为支持COMMENT或ACTIVITY,但不支持APPROVAL。