Stash 中的拉取请求指标
Pull Request Metrics in Stash
我们被要求生成关于我们进行了多少代码审查的指标。 Stash/Git 中有没有办法提取对回购执行的历史拉取请求?特别是,以下内容很有用:
请求- Date/Time
- 请求者姓名
- 批准人姓名
认可- Date/Time
正如 , you can use the Stash REST APIs for this, more specifically the Stash Core REST API 所建议的那样,为服务器管理、项目、存储库、拉取请求和用户管理等核心 Stash 功能提供 REST 资源:
GET
/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests yields the paged 针对相关回购的开放拉取请求列表。响应包含您正在查找的大部分信息,特别是拉取请求日期、author
、reviewers
甚至 participants
:
{
"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
}
批准日期
仍然缺少批准的确切日期,但如果您碰巧使用 Checks for merging pull requests 并且需要至少一次批准,您可以从拉取请求 closed
日期中估算它。
- 理想情况下 /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/activities 上的
GET
应该 return 每个评论者的这些细节,但不幸的是 fromType
仅记录为支持 COMMENT 或 ACTIVITY ,但不批准。
- 如果你想要这个功能,我建议观看(vote/comment相关问题Indicate which pull request approvals are "out of date" (BSERV-3887)(当然也可以打开一个更精确的新问题)。
我们被要求生成关于我们进行了多少代码审查的指标。 Stash/Git 中有没有办法提取对回购执行的历史拉取请求?特别是,以下内容很有用:
-
请求
- Date/Time
- 请求者姓名
- 批准人姓名 认可
- Date/Time
正如
GET
/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests yields the paged 针对相关回购的开放拉取请求列表。响应包含您正在查找的大部分信息,特别是拉取请求日期、author
、reviewers
甚至 participants
:
{
"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
}
批准日期
仍然缺少批准的确切日期,但如果您碰巧使用 Checks for merging pull requests 并且需要至少一次批准,您可以从拉取请求 closed
日期中估算它。
- 理想情况下 /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/activities 上的
GET
应该 return 每个评论者的这些细节,但不幸的是fromType
仅记录为支持 COMMENT 或 ACTIVITY ,但不批准。 - 如果你想要这个功能,我建议观看(vote/comment相关问题Indicate which pull request approvals are "out of date" (BSERV-3887)(当然也可以打开一个更精确的新问题)。