# SVN 代码评审(SVN Review)
如果使用 project_full_path,确保 project_full_path 编码过,例子:/api/v3/svn/projects/tencent/code--> /api/v3/svn/projects/tencent%2Fcode (/ 编码 %2F)
CR 评审状态值(review_state)说明:
approved:评审通过
approving:评审中
change_denied:评审被拒绝
change_required:代码要求修改
closed:被关闭了
# 新建 SVN 代码在服务器的评审
在 SVN 项目中新建一个代码在服务器的评审
审批人规则:
-1:所有评审人通过,1:单评审通过,2+:多评审通过 (用>=2 的数字代表需要几位必要评审人通过)。必要审批人规则:
-1:所有必要评审人通过,1:单必要评审通过,2+:多必要评审通过 (用>=2 的数字代表需要几位必要评审人通过),0: 不需要必要评审人即可通过。可以通过 2 种方式在发起 CR 请求的时候指定需要添加的 tapd 单信息:
1:通过 workspace_id、tapd_id、tapd_type 三个字段指定一个 tapd 单,2:通过 tapd_info 指定一个 tapd 单
POST /api/v3/svn/projects/:id/reviews
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
| title | string | 标题 |
| review_path | string | 发起 CR 的代码路径 |
| source_revision | string | 源版本号(大版本号) |
| target_revision | string | 目标版本号(小版本号) |
| description | string(可选) | 描述 |
| labels | string(可选) | 合并请求的标签,多个请用英文逗号分隔 |
| reviewer_ids | string(可选) | 评审人 id或用户名 (支持id和用户名混用。多个评审人请用英文逗号分隔) |
| creator | string(可选) | 创建者英文名 |
| approver_rule | Integer(可选) | 评审人规则 |
| workspace_id | Integer (可选) | tapd 工作区 ID |
| tapd_id | Long (可选) | tapd 单 ID |
| tapd_type | string (可选) | tapd 单类型,可选值:story、bug、task |
| tapd_info | string (可选) | tapd 源码提交关键字,例如:--story=864823135 wefwf |
| selected_files | array of string (可选) | 指定需要评审的文件路径数组,参数为空时默认传所有文件 |
返回值:
{
"labels": [],
"title": "代码在服务器的评审",
"description": "代码在服务器的评审的描述",
"target_revision": "1",
"project_id": 1132262,
"source_revision": "4",
"path": null,
"author": {
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
},
"reviewers": [
{
"type": "suggestion",
"review_state": "approving",
"review_duration": 0,
"created_at": "2023-09-06T07:54:59+0000",
"updated_at": "2023-09-06T07:54:59+0000",
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
}
],
"id": 102423280,
"reviewable_id": 100144158,
"reviewable_type": "comparison",
"iid": 38,
"state": "approving",
"approver_rule": 1,
"necessary_approver_rule": 0,
"push_reset_enabled": true,
"push_reset_rule": 0,
"created_at": "2023-09-06T07:54:59+0000",
"updated_at": "2023-09-06T07:54:59+0000",
"owners": [
{
"id": 615315308,
"ownerId": 188733,
"reviewId": 102423280,
"projectId": 1132262,
"filePath": "/trunk/t.txt",
"noteId": 0,
"noteContent": "",
"approverRule": "none",
"ownerRuleConfig": {
"count": 1
},
"isOwnerReviewable": true,
"ownerType": 0,
"isFileReviewable": true,
"createdAt": "2023-09-06T07:54:59+0000",
"updatedAt": "2023-09-06T07:54:59+0000",
"state": "approving",
"pathCrc": 48264584,
"filePathReviewState": "empty",
"user": {
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
},
"username": "user",
"userId": 188733,
"fileReviewable": true,
"ownerReviewable": true,
"reviewState": true,
"resultState": false,
"reviewable": true
}
]
}
# 新建 SVN 代码在服务器的修订集
在 SVN 代码在服务器的评审中新建一个修订集
POST /api/v3/svn/projects/:id/reviews/:review_id/patch_sets
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
| review_id | Integer | 代码评审 ID |
| review_path | string | 发起 CR 的代码路径 |
| source_revision | string | 源版本号(大版本号) |
| target_revision | string | 目标版本号(小版本号) |
| description | string(可选) | 描述 |
| creator | string(可选) | 修订集创建者英文名 |
| selected_files | array of string (可选) | 指定需要评审的文件路径数组,参数为空时默认传所有文件 |
返回值:
{
"labels": [],
"title": "代码在服务器的评审",
"description": "代码在服务器的评审的描述",
"target_revision": "1",
"project_id": 1132262,
"source_revision": "4",
"path": null,
"author": {
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
},
"reviewers": [
{
"type": "suggestion",
"review_state": "approving",
"review_duration": 0,
"created_at": "2023-09-06T07:54:59+0000",
"updated_at": "2023-09-06T07:54:59+0000",
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
}
],
"id": 102423280,
"reviewable_id": 100144158,
"reviewable_type": "comparison",
"iid": 38,
"state": "approving",
"approver_rule": 1,
"necessary_approver_rule": 0,
"push_reset_enabled": true,
"push_reset_rule": 0,
"created_at": "2023-09-06T07:54:59+0000",
"updated_at": "2023-09-06T07:54:59+0000",
"owners": [
{
"id": 615315308,
"ownerId": 188733,
"reviewId": 102423280,
"projectId": 1132262,
"filePath": "/trunk/t.txt",
"noteId": 0,
"noteContent": "",
"approverRule": "none",
"ownerRuleConfig": {
"count": 1
},
"isOwnerReviewable": true,
"ownerType": 0,
"isFileReviewable": true,
"createdAt": "2023-09-06T07:54:59+0000",
"updatedAt": "2023-09-06T07:54:59+0000",
"state": "approving",
"pathCrc": 48264584,
"filePathReviewState": "empty",
"user": {
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
},
"username": "user",
"userId": 188733,
"fileReviewable": true,
"ownerReviewable": true,
"reviewState": true,
"resultState": false,
"reviewable": true
}
]
}
# 获取 SVN 项目中的代码评审
获取 SVN 项目中所有的代码评审
GET /api/v3/svn/projects/:id/reviews
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
| author_id | integer(可选) | 作者的 id |
| iids[] | array of integer(可选) | 项目里面的 review id 编号,使用时需转义. 如:iids[]=1&iids[]=2 --> iids%5B%5D=1&iids%5B%5D=2 |
| state | string(可选) | 评审状态,可选值:approving, approved change_required 或 closed,不填写或填写all返回所有的代码评审。 |
| reviewable_type | string(可选) | 评审类型,可选值:comparison代码在服务器, svn_merge_request 代码在本地。 |
| labels | string(可选) | 合并请求的标签,多个请用英文逗号分隔 |
| order_by | string(可选) | 排序字段,允许按 created_at, updated_at 排序(默认 created_at) |
| sort | string(可选) | 排序方式,允许 asc or desc(默认 desc) |
| page | integer(可选) | 分页(默认值:1) |
| per_page | integer(可选) | 默认页面大小(默认值: 20,最大值: 100) |
返回值:
[
{
"labels": [],
"title": "代码在服务器的评审",
"description": "代码在服务器的评审的描述",
"target_revision": "1",
"project_id": 1132262,
"source_revision": "4",
"path": null,
"author": {
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
},
"reviewers": [
{
"type": "suggestion",
"review_state": "approving",
"review_duration": 0,
"created_at": "2023-09-06T07:54:59+0000",
"updated_at": "2023-09-06T07:54:59+0000",
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
}
],
"id": 102423280,
"project_id": 11242475,
"reviewable_id": 100144158,
"reviewable_type": "comparison",
"iid": 38,
"state": "approving",
"approver_rule": 1,
"necessary_approver_rule": 0,
"push_reset_enabled": true,
"push_reset_rule": 0,
"created_at": "2023-09-06T07:54:59+0000",
"updated_at": "2023-09-06T07:54:59+0000",
"owners": [
{
"id": 615315308,
"ownerId": 188733,
"reviewId": 102423280,
"projectId": 1132262,
"filePath": "/trunk/t.txt",
"noteId": 0,
"noteContent": "",
"approverRule": "none",
"ownerRuleConfig": {
"count": 1
},
"isOwnerReviewable": true,
"ownerType": 0,
"isFileReviewable": true,
"createdAt": "2023-09-06T07:54:59+0000",
"updatedAt": "2023-09-06T07:54:59+0000",
"state": "approving",
"pathCrc": 48264584,
"filePathReviewState": "empty",
"user": {
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
},
"username": "user",
"userId": 188733,
"fileReviewable": true,
"ownerReviewable": true,
"reviewState": true,
"resultState": false,
"reviewable": true
}
]
}
]
# 获取 SVN 项目中某个具体的代码评审 (根据 id)
获取 SVN 项目中某个具体的代码评审情况。
GET /api/v3/svn/projects/:id/reviews/:review_id
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
| review_id | integer | 代码评审的 id |
返回值:
{
"labels": [],
"title": "代码在服务器的评审",
"description": "代码在服务器的评审的描述",
"target_revision": "1",
"project_id": 1132262,
"source_revision": "4",
"path": null,
"author": {
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
},
"reviewers": [
{
"type": "suggestion",
"review_state": "approving",
"review_duration": null,
"created_at": "2023-09-06T07:54:59+0000",
"updated_at": "2023-09-06T07:54:59+0000",
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
}
],
"id": 102423280,
"project_id": 11242475,
"reviewable_id": 100144158,
"reviewable_type": "comparison",
"iid": 38,
"state": "approving",
"approver_rule": 1,
"necessary_approver_rule": 0,
"push_reset_enabled": true,
"push_reset_rule": 0,
"created_at": "2023-09-06T07:54:59+0000",
"updated_at": "2023-09-06T07:54:59+0000",
"owners": [
{
"id": 615315308,
"ownerId": 188733,
"reviewId": 102423280,
"projectId": 1132262,
"filePath": "/trunk/t.txt",
"noteId": 0,
"noteContent": "",
"approverRule": "none",
"ownerRuleConfig": {
"count": 1
},
"isOwnerReviewable": true,
"ownerType": 0,
"isFileReviewable": true,
"createdAt": "2023-09-06T07:54:59+0000",
"updatedAt": "2023-09-06T07:54:59+0000",
"state": "approving",
"pathCrc": 48264584,
"filePathReviewState": "empty",
"user": {
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
},
"username": "user",
"userId": 188733,
"ownerReviewable": true,
"resultState": false,
"reviewable": true,
"fileReviewable": true,
"reviewState": true
}
]
}
# 获取 SVN 项目中某个具体的代码评审 (根据 iid)
获取 SVN 项目中某个具体的代码评审情况。
GET /api/v3/svn/projects/:id/reviews/iid/:review_iid
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
| review_iid | integer | 代码评审在项目中的编号 iid |
返回值:
{
"labels": [],
"title": "代码在服务器的评审",
"description": "代码在服务器的评审的描述",
"target_revision": "1",
"project_id": 1132262,
"source_revision": "4",
"path": null,
"author": {
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
},
"reviewers": [
{
"type": "suggestion",
"review_state": "approving",
"review_duration": null,
"created_at": "2023-09-06T07:54:59+0000",
"updated_at": "2023-09-06T07:54:59+0000",
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
}
],
"id": 102423280,
"reviewable_id": 100144158,
"reviewable_type": "comparison",
"iid": 38,
"state": "approving",
"approver_rule": 1,
"necessary_approver_rule": 0,
"push_reset_enabled": true,
"push_reset_rule": 0,
"created_at": "2023-09-06T07:54:59+0000",
"updated_at": "2023-09-06T07:54:59+0000",
"owners": [
{
"id": 615315308,
"ownerId": 188733,
"reviewId": 102423280,
"projectId": 1132262,
"filePath": "/trunk/t.txt",
"noteId": 0,
"noteContent": "",
"approverRule": "none",
"ownerRuleConfig": {
"count": 1
},
"isOwnerReviewable": true,
"ownerType": 0,
"isFileReviewable": true,
"createdAt": "2023-09-06T07:54:59+0000",
"updatedAt": "2023-09-06T07:54:59+0000",
"state": "approving",
"pathCrc": 48264584,
"filePathReviewState": "empty",
"user": {
"id": 188733,
"username": "user",
"web_url": "http://git.tencent.com/u/user",
"name": "user",
"state": "active",
"avatar_url": "https://git.tencent.com/common/images/avatar/default_user_avatar.png"
},
"username": "user",
"userId": 188733,
"ownerReviewable": true,
"resultState": false,
"reviewable": true,
"fileReviewable": true,
"reviewState": true
}
]
}
# 邀请评审人
给项目中的评审添加评审人
POST /api/v3/svn/projects/:id/review/:review_id/invite
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
| review_id | integer | 代码评审的 id |
| reviewer_id | integer | 评审人 id (只能是 id。多个评审人请用英文逗号分隔) |
返回值:
{
"labels": [],
"title": "api 增加 reviewer_id",
"description": null,
"author": {
"id": 0001,
"username": "git_user01",
"web_url": "https://git.tencent.com/u/git_user01",
"name": "git_user01",
"state": "active",
"avatar_url": "https://git.tencent.com/assets/images/avatar/no_user_avatar.png"
},
"reviewers": [
{
"id": 0002,
"username": "git_user02",
"web_url": "https://git.tencent.com/u/git_user02",
"name": "git_user02",
"state": "active",
"avatar_url": "https://git.tencent.com/assets/images/avatar/no_user_avatar.png",
"type": "invite",
"review_state": "approving",
"created_at": "2019-04-19T08:30:20+0000",
"updated_at": "2019-04-19T08:30:20+0000"
}
],
"id": 276502,
"project_id": 9837556,
"reviewable_id": 108,
"reviewable_type": "comparison",
"state": "approving",
"approver_rule": 1,
"necessary_approver_rule": 0,
"push_reset_enabled": true,
"created_at": "2019-04-19T08:01:54+0000",
"updated_at": "2019-04-19T08:30:15+0000"
}
# 批量邀请评审人
给项目中的评审批量添加评审人
POST /api/v3/svn/projects/:id/review/:review_id/batch_invite
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
| review_id | integer | 代码评审的 id |
| reviewer_ids[] | array of integer | 评审人的 id 列表,限制数量最大为 100 个 |
返回值:
{
"labels": [],
"title": "api 增加 reviewer_id",
"description": null,
"author": {
"id": 0001,
"username": "git_user01",
"web_url": "https://git.tencent.com/u/git_user01",
"name": "git_user01",
"state": "active",
"avatar_url": "https://git.tencent.com/assets/images/avatar/no_user_avatar.png"
},
"reviewers": [
{
"id": 0002,
"username": "git_user02",
"web_url": "https://git.tencent.com/u/git_user02",
"name": "git_user02",
"state": "active",
"avatar_url": "https://git.tencent.com/assets/images/avatar/no_user_avatar.png",
"type": "invite",
"review_state": "approving",
"created_at": "2019-04-19T08:30:20+0000",
"updated_at": "2019-04-19T08:30:20+0000"
}
],
"id": 276502,
"project_id": 9837556,
"reviewable_id": 108,
"reviewable_type": "comparison",
"state": "approving",
"approver_rule": 1,
"necessary_approver_rule": 0,
"push_reset_enabled": true,
"created_at": "2019-04-19T08:01:54+0000",
"updated_at": "2019-04-19T08:30:15+0000",
"fail_list":[
{
"user_id":1126,
"msg":"403 forbidden, for reviewer:1126 is blocked"
},
{
"user_id":1126,
"msg":"403 forbidden, for necessary reviewer:1126 is blocked"
},
{
"user_id":2274,
"msg":"403 forbidden"
}
]
}
# 移除评审人
在项目中的评审中移除某位评审人
DELETE /api/v3/svn/projects/:id/review/:review_id/dismissals
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
| review_id | integer | 代码评审的 id |
| reviewer_id | Integer | 评审人 id |
返回值:
200等相关状态码
# 更新评审
在项目内更新某个指定的评审
- 可以通过 2 种方式在更新 CR 时指定需要添加的 tapd 单信息:
1:通过 workspace_id、tapd_id、tapd_type 三个字段指定一个 tapd 单,2:通过 tapd_info 指定一个 tapd 单
PUT /api/v3/svn/projects/:id/review/:review_id
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer 或 string | 项目 ID 或 项目全路径 project_full_path |
| review_id | integer | 代码评审的 id |
| title | string | 代码评审的标题 |
| description | string(可选) | 代码评审的描述 |
| labels | string(可选) | 合并请求的标签,多个请用英文逗号分隔 |
| workspace_id | integer (可选) | tapd 工作区 ID |
| tapd_id | Long (可选) | tapd 单 ID |
| tapd_type | string (可选) | tapd 单类型,可选值:story、bug、task |
| tapd_info | string (可选) | tapd 源码提交关键字,例如:--story=864823135 wefwf |
返回值:
{
"labels": [],
"title": "修改标题",
"description": "创建一个评审意见",
"author": {
"id": 0001,
"username": "git_user01",
"web_url": "https://git.tencent.com/u/git_user01",
"name": "git_user01",
"state": "active",
"avatar_url": "https://git.tencent.com/assets/images/avatar/no_user_avatar.png"
},
"reviewers": [
{
"id": 0002,
"username": "git_user02",
"web_url": "https://git.tencent.com/u/git_user02",
"name": "git_user01",
"state": "active",
"avatar_url": "https://git.tencent.com/assets/images/avatar/no_user_avatar.png",
"type": "suggestion",
"review_state": "approving",
"created_at": "2019-04-19T09:03:50+0000",
"updated_at": "2019-04-19T09:11:33+0000"
}
],
"id": 276504,
"project_id": 9837556,
"reviewable_id": 110,
"reviewable_type": "comparison",
"state": "approving",
"approver_rule": 1,
"necessary_approver_rule": 0,
"push_reset_enabled": true,
"created_at": "2019-04-19T09:03:50+0000",
"updated_at": "2019-04-19T09:11:33+0000"
}