# Pulls
## 获取一个合并请求
获取合并请求详情接口
> 示例:
```shell
curl -X GET http://localhost:3000/api/v1/yystopf/ceshi_commit/pulls/1.json
```
```javascript
await octokit.request('GET /api/v1/yystopf/ceshi_commit/pulls/1.json')
```
### HTTP 请求
`GET /api/v1/:owner/:repo/pulls/:index.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|owner |是| |string |用户登录名 |
|repo |是| |string |项目标识identifier |
|index |是| | integer | pull 序号 |
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|-|-|-|
|id |int|合并请求ID|
|title |string|合并请求标题|
|body| |string|合并请求内容|
|head |int|合并请求源分支|
|base |int|合并请求目标分支|
|index |int|合并请求序号|
|status |string|合并请求状态,open: 开启的, merged: 合并的, closed: 关闭的|
|issue.id |int|疑修ID|
|issue.author |object|疑修作者|
|issue.priority |string|疑修优先级|
|issue.version |string|疑修里程碑|
|issue.journals_count |int|普通评论数量|
|issue.issue_tags |array|标记|
|journals_count |int|审查评论数量|
|merge_base |string|目标的commit ID|
|base_commit_sha |string|合并之后的第一个commit ID|
|head_commit_sha |string|源commit ID|
|commit_num |int|commit数量|
|changed_files |int|更改文件数量|
|is_locked |bool||
|mergeable |bool|是否能合并|
|merged |bool|是否合并|
|merged_at |string|合并时间|
|merge_commit_sha |string|合并之后的第一个commit ID|
|merge_by |object|被谁合并了|
|last_review.id |int|最后一个审查的id|
|last_review.commit_id|string|最后一个审查对应的commit ID|
|last_review.content |string|最后一个审查的内容|
|last_review.status |string|最后一个审查的状态,common: 一般审查, approved: 通过, rejected: 拒绝通过|
|last_review.created_at|string|审查创建的时间|
|last_review.reviewer |object|审查创建人|
|reviewers |array|指定审查用户标识数组|
|conflict_files |array|有冲突的文件|
> 返回的JSON示例:
```json
{
"id": 168,
"head": "new_branch",
"base": "master",
"is_original": false,
"index": 5,
"status": "merged",
"issue": {
"id": 265,
"author": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"priority": null,
"version": null,
"journals_count": 1,
"issue_tags": null
},
"journals_count": 0,
"merge_base": "4a277037093c1248e46d2946ee30b61cccdb9df9",
"base_commit_sha": "dbb510cd852a6bfd4d71a1f84921aa3170654590",
"head_commit_sha": "0f0e27918eb5deb8d514012d84d13db10eebe19a",
"commit_num": 1,
"changed_files": 1,
"is_locked": false,
"mergeable": true,
"merged": true,
"merged_at": 1658743004,
"merge_commit_sha": "dbb510cd852a6bfd4d71a1f84921aa3170654590",
"merge_by": {
"id": null,
"login": "yystopf",
"name": "yystopf",
"type": null,
"image_url": "system/lets/letter_avatars/2/Y/241_125_89/120.png"
},
"last_review": {
"id": 5,
"commit_id": null,
"content": "新建一个审查",
"status": "common",
"created_at": "2022-07-25 17:08",
"reviewer": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
}
},
"reviewers": [
"yystopf"
],
"conflict_files": []
}
```
## 获取合并请求文件列表
获取合并请求文件列表
> 示例:
```shell
curl -X GET \
http://localhost:3000/api/Jason/gitlink/pulls/1/files.json
```
```javascript
await octokit.request('GET /api/jasder/gitlink/pulls/1/files.json')
```
### HTTP 请求
`GET /api/:owner/:repo/pulls/:id/files.json`
### 请求参数:
|参数名|必选|类型|说明|
|-|-|-|-|
|owner |是|string |用户登录名 |
|repo |是|string |project's identifier |
|id |是|int |pull request's id |
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|-|-|-|
|files_count |int|文件更改的总数量|
|total_addition |int|添加代码总行数|
|total_deletion |int|删除代码总行数|
|files |array||
|-- sha |string|commit's sha value|
|-- name |string|当前文件名|
|-- old_name |string| 修改之前的文件名称,与name相同的话,说明文件名未更改|
|-- addition |int|文件添加的行数|
|-- deletion |int|文件删除的行数|
|-- type |int|文件类型, 1: 表示该文件只添加了内容,2: 表示该文件内容有修改, 3: 表示文件被删除或者改文件只删除了内容|
|-- isCreated |boolean|当前文件是否为新增文件, true: 是, false: 否|
|-- isDeleted |boolean|当前文件是否被删除, true: 是,false: 否|
|-- isBin |boolean|当前文件是否为二进制文件,true: 是,false: 否|
|-- isLFSFile |boolean|当前文件是否为LFS文件,true: 是,false: 否|
|-- isRenamed |boolean|当前文件是否被重命名,true: 是,false: 否|
|-- sections |array||
|---- fileName |string|文件名称|
|---- lines |array||
|------ leftIdx |string|文件变动之前所在行数|
|------ rightIdx |string|文件更改后所在行数|
|------ type |string|文件变更类型,1: 新增,2: 修改, 3: 删除, 4: diff统计信息|
|------ content |string|文件变更的内容|
|------ sectionInfo |object||
|-------- path |string|文件相对仓库的路径|
|-------- lastLeftIdx |int||
|-------- lastRightIdx |int||
|-------- leftHunkSize |int|文件变更之前的行数|
|-------- rightHunkSize |int|文件变更之后的行数(及当前页面编辑器显示的总行数)|
|-------- leftIdx |int|文件变更之前所在行数|
|-------- rightIdx |int|文件变更之后所在行数(即:页面编辑器开始显示的行数)|
> 返回的JSON示例:
```json
{
"files_count": 6,
"total_addition": 447,
"total_deletion": 0,
"files": [
{
"sha": "xefenisnii",
"name": "文件.txt",
"old_name": "文件.txt",
"index": 6,
"addition": 2,
"deletion": 0,
"type": 1,
"isCreated": true,
"isDeleted": false,
"isBin": false,
"isLFSFile": false,
"isRenamed": false,
"isSubmodule": false,
"sections": [
{
"fileName": "文件.txt",
"name": "",
"lines": [
{
"leftIdx": 0,
"rightIdx": 0,
"type": 4,
"content": "@@ -0,0 +1,2 @@",
"sectionInfo": {
"path": null,
"lastLeftIdx": null,
"lastRightIdx": null,
"leftIdx": 0,
"rightIdx": 0,
"leftHunkSize": null,
"rightHunkSize": null
}
},
{
"leftIdx": 0,
"rightIdx": 1,
"type": 2,
"content": "+用例图一致性更新",
"sectionInfo": null
},
{
"leftIdx": 0,
"rightIdx": 2,
"type": 2,
"content": "+工程文件直接上传会有文件缺失,现在压缩后上传",
"sectionInfo": null
}
]
}
]
}
]
}
```
## 获取合并请求的commits列表
获取合并请求的commits列表
> 示例:
```shell
curl -X GET http://localhost:3000/api/jasder/jasder_test/pulls/1/commits.json
```
```javascript
await octokit.request('GET /api/jasder/jasder_test/pulls/1/commits.json')
```
### HTTP 请求
`GET /api/:owner/:repo/pulls/:id/commits.json`
### 请求参数:
|参数名|必选|类型|说明|
|-|-|-|-|
|owner |是|string |用户登录名 |
|repo |是|string |project's identifier |
|id |是|int |pull request's id |
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|commits_count |int|commits总数量|
|commits |array||
|-- author |object|项目作者|
|---- login |string|用户login|
|---- name |string|用户姓名|
|---- image_url |string|用户头像|
|-- committer |object|commit提交用户|
|---- login |string|用户login|
|---- name |string|用户姓名|
|---- image_url |string|用户头像|
|-- timestamp |int|commit的unix时间戳|
|-- time_from_now|string|commit’s 提交时间距当前时间的时间值|
|-- message |string|commit说明信息|
|-- sha |string|commit’s sha值|
> 返回的JSON示例:
```json
{
"commits_count": 1,
"commits": [
{
"author": {
"id": 36480,
"login": "jasder",
"name": "段甲生",
"image_url": "avatars/User/b"
},
"committer": {
"id": 36480,
"login": "jasder",
"name": "段甲生",
"image_url": "avatars/User/b"
},
"timestamp": 1604382982,
"time_from_now": "3小时前",
"message": "add some file\n* Add the tag list page to the release page\n* Apply suggestions from code review\n* Add the tags list view\n* Add the delete tag way on ui\n* Not delete tag and clear message when delete a release\n",
"sha": "8f5faee0d3b3be1b8063e84da0c79dd75327b968"
}
]
}
```
## Compare two commits
Compare two commits
> 示例:
```shell
curl -X GET \
http://localhost:3000/api/Jason/test-txt/compare/master...develop
curl -X GET \
http://localhost:3000/api/Jason/test-txt/compare/master...Jason/test-txt:develop
```
```javascript
await octokit.request('GET /api/Jason/test-txt/compare/master...Jason/test-txt:develop')
```
### HTTP 请求
`GET /api/:owner/:repo/compare/{base}...{head}.json`
### 请求参数:
|参数名|必选|类型|说明|
|-|-|-|-|
|owner |是|string |用户登录名 |
|repo |是|string |project's identifier |
|base |是|string |pull request's id |
|head |是|string |pull request's id |
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|-|-|-|
|commits_count |int|commits总数量|
|commits |array||
|-- author |object|项目作者|
|---- login |string|用户login|
|---- name |string|用户姓名|
|---- image_url |string|用户头像|
|-- committer |object|commit提交用户|
|---- login |string|用户login|
|---- name |string|用户姓名|
|---- image_url |string|用户头像|
|-- timestamp |int|commit的unix时间戳|
|-- time_from_now|string|commit’s 提交时间距当前时间的时间值|
|-- message |string|commit说明信息|
|-- sha |string|commit’s sha值|
|diff |object||
|-- files_count |int|文件更改的总数量|
|-- total_addition |int|添加代码总行数|
|-- total_deletion |int|删除代码总行数|
|-- files |Array||
|-- sha |string|commit's sha |
|-- name |string|当前文件名|
|-- old_name |string| 修改之前的文件名称,与name相同的话,说明文件名未更改|
|-- addition |int|文件添加的行数|
|-- deletion |int|文件删除的行数|
|-- type |int|文件类型, 1: 表示该文件只添加了内容,2: 表示该文件内容有修改, 3: 表示文件被删除或者改文件只删除了内容|
|-- isCreated |boolean|当前文件是否为新增文件, true: 是, false: 否|
|-- isDeleted |boolean|当前文件是否被删除, true: 是,false: 否|
|-- isBin |boolean|当前文件是否为二进制文件,true: 是,false: 否|
|-- isLFSFile |boolean|当前文件是否为LFS文件,true: 是,false: 否|
|-- isRenamed |boolean|当前文件是否被重命名,true: 是,false: 否|
|-- sections |array||
|---- fileName |string|文件名称|
|---- lines |array||
|------ leftIdx |string|文件变动之前所在行数|
|------ rightIdx |string|文件更改后所在行数|
|------ type |string|文件变更类型,1: 内容未改动,2: 添加, 3: 删除, 4: diff统计信息|
|------ content |string|文件变更的内容|
|------ sectionInfo |object||
|-------- path |string|文件相对仓库的路径|
|-------- lastLeftIdx |int||
|-------- lastRightIdx |int||
|-------- leftHunkSize |int|文件变更之前的行数|
|-------- rightHunkSize |int|文件变更之后的行数(及当前页面编辑器显示的总行数)|
|-------- leftIdx |int|文件变更之前所在行数|
|-------- rightIdx |int|文件变更之后所在行数|
> 返回的JSON示例:
```json
{
"commits_count": 1,
"commits": [
{
"author": {
"id": 36480,
"login": "jasder",
"name": "段甲生",
"image_url": "avatars/User/b"
},
"committer": {
"id": 36480,
"login": "jasder",
"name": "段甲生",
"image_url": "avatars/User/b"
},
"timestamp": 1604382982,
"time_from_now": "4小时前",
"message": "add some file\n* Add the tag list page to the release page\n* Apply suggestions from code review\n* Add the tags list view\n* Add the delete tag way on ui\n* Not delete tag and clear message when delete a release\n",
"sha": "8f5faee0d3b3be1b8063e84da0c79dd75327b968"
}
],
"diff": {
"files_count": 6,
"total_addition": 447,
"total_deletion": 0,
"files": [
{
"name": "build.go",
"old_name": "build.go",
"index": 1,
"addition": 33,
"deletion": 0,
"type": 1,
"isCreated": true,
"isDeleted": false,
"isBin": false,
"isLFSFile": false,
"isRenamed": false,
"isSubmodule": false,
"sections": [
{
"fileName": "build.go",
"name": "",
"lines": [
{
"leftIdx": 0,
"rightIdx": 0,
"type": 4,
"content": "@@ -0,0 +1,33 @@",
"sectionInfo": {
"path": "build.go",
"lastLeftIdx": 0,
"lastRightIdx": 0,
"leftIdx": 0,
"rightIdx": 1,
"leftHunkSize": 0,
"rightHunkSize": 33
}
},
{
"leftIdx": 0,
"rightIdx": 1,
"type": 2,
"content": "+// Copyright 2020 The Gitea Authors. All rights reserved.",
"sectionInfo": null
}
]
}
]
}
]
}
```
## 获取合并请求列表
获取合并请求列表
> 示例:
```shell
curl -X GET http://localhost:3000/api/v1/yystopf/ceshi_commit/pulls.json
```
```javascript
await octokit.request('GET /api/v1/yystopf/ceshi_commit/pulls.json')
```
### HTTP 请求
`GET /api/v1/:owner/:repo/pulls.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|owner |是| |string |用户登录名 |
|repo |是| |string |项目标识identifier |
|keyword |否| |string |搜索关键词|
|status |否| | int | 合并请求类型 0: 开启的, 1: 合并的 2: 关闭的,不传则为全部的 |
|priority_id |否| | int | 优先级ID |
|issue_tag_id |否| |int|标记ID|
|version_id |否| |int|里程碑ID|
|reviewer_id |否| |int| 审查人员ID|
|assign_user_id |否| |int| 指派人员ID|
|sort_by |否| created_at |string| 排序字段,created_at: 创建时间, updated_at: 更新时间|
|sort_direction |否| desc |string| 排序类型 desc: 倒序 asc: 正序|
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|-|-|-|
|total_count |int|合并请求总数|
|id |int|合并请求ID|
|title |string|合并请求标题|
|body |string|合并请求内容|
|head |int|合并请求源分支|
|base |int|合并请求目标分支|
|index |int|合并请求序号|
|is_original |bool|是否为fork仓库发来的合并请求|
|status |string|合并请求状态,open: 开启的, merged: 合并的, closed: 关闭的|
|fork_project.id |int|fork仓库的id|
|fork_project.identifier|string|fork仓库的标识|
|fork_project.login |string|fork仓库拥有者的标识|
|issue.id |int|疑修ID|
|issue.author |object|疑修作者|
|issue.priority |string|疑修优先级|
|issue.version |string|疑修里程碑|
|issue.journals_count |int|普通评论数量|
|issue.issue_tags |array|标记|
|journals_count |int|审查评论数量|
> 返回的JSON示例:
```json
{
"total_count": 2,
"pulls": [
{
"id": 167,
"head": "master",
"base": "master",
"is_original": true,
"index": 4,
"status": "open",
"fork_project": {
"id": 491,
"identifier": "ceshi_commit",
"login": "testforge1"
},
"issue": {
"id": 264,
"author": {
"id": 4,
"type": "User",
"name": "tes tforge1",
"login": "testforge1",
"image_url": "system/lets/letter_avatars/2/T/238_117_19/120.png"
},
"priority": null,
"version": null,
"journals_count": 0,
"issue_tags": null
},
"journals_count": 0
},
{
"id": 165,
"head": "master_1",
"base": "master",
"is_original": false,
"index": 3,
"status": "open",
"issue": {
"id": 262,
"author": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"priority": null,
"version": null,
"journals_count": 0,
"issue_tags": null
},
"journals_count": 0
}
]
}
```
## 创建一个合并请求
为仓库创建一个合并请求
> 示例:
```shell
curl -X POST \
http://localhost:3000/api/yystopf/ceshi/pulls.json
```
```javascript
await octokit.request('POST /api/yystopf/ceshi/pulls.json')
```
### HTTP 请求
`POST /api/:owner/:repo/pulls.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|owner |是| | string |用户登录名 |
|repo |是| | string |项目标识identifier |
|title |是| | string |合并请求标题|
|body |否| | string |合并请求内容|
|base |是| | string |目标分支|
|head |是| | string |源分支|
|is_original |是| | bool |是否为fork仓库发来的合并请求|
|fork_project_id |否| | integer|fork仓库ID|
|reviewer_ids |否| | array |审查人员id数组|
|assigned_to_id |否| | integer|指派人员ID|
|fixed_version_id |否| | integer|里程碑ID|
|issue_tag_ids |否| | array |标记ID数组|
|priority_id |否| | integer|优先级ID|
|receivers_login |否| | array |@人员的login|
> 请求的JSON示例:
```json
{
"title": "324",
"assigned_to_id": "2",
"fixed_version_id": "",
"issue_tag_ids": [],
"priority_id": "2",
"body": "312",
"head": "new_branch_1",
"base": "master",
"is_original": false,
"fork_project_id": "",
"files_count": 1,
"commits_count": 1,
"reviewer_ids": [],
"receivers_login": []
}
```
> 返回的JSON示例:
```json
{
"status": 0,
"message": "响应成功",
"pull_request_id": 169,
"pull_request_number": 6,
"pull_request_status": 0,
"pull_request_head": "new_branch_1",
"pull_request_base": "master",
"pull_request_staus": "open",
"is_original": false,
"fork_project_id": null,
"fork_project_identifier": null,
"fork_project_user": null,
"reviewers": [
"yystopf"
],
"id": 266,
"name": "324",
"pr_time": "1分钟前",
"assign_user_name": "heh",
"assign_user_login": "yystopf",
"author_name": "heh",
"author_login": "yystopf",
"avatar_url": "system/lets/letter_avatars/2/H/188_239_142/120.png",
"priority": "正常",
"version": null,
"journals_count": 0,
"issue_tags": null
}
```
## 获取合并请求版本列表
获取合并请求版本列表
> 示例:
```shell
curl -X GET http://localhost:3000/api/v1/yystopf/ceshi_commit/pulls/3/versions.json
```
```javascript
await octokit.request('GET /api/v1/yystopf/ceshi_commit/pulls/3/versions.json')
```
### HTTP 请求
`GET /api/v1/:owner/:repo/pulls/:index/versions.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|owner |是| |string |用户登录名 |
|repo |是| |string |项目标识identifier |
|index |是|| int |合并请求序号|
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|total_count |int |合并请求版本总数|
|versions.id |int |版本ID|
|versions.add_line_num |int |该版本新增行数|
|versions.del_line_num |int |该版本删除行数|
|versions.commits_count |int |该版本提交总数|
|versions.files_count |int |该版本提交文件总数|
|versions.base_commit_sha |string |目标commit ID|
|versions.head_commit_sha |string |源commit ID|
|versions.start_commit_sha|string |该版本起始commit ID|
|versions.created_time |int |版本创建时间|
|versions.updated_time |int |版本更新时间|
> 返回的JSON示例:
```json
{
"total_count": 1,
"versions": [
{
"id": 33,
"add_line_num": 5,
"del_line_num": 2,
"commits_count": 31,
"files_count": 29,
"base_commit_sha": "4a277037093c1248e46d2946ee30b61cccdb9df9",
"head_commit_sha": "fa3b1cdc8e0727d0fb9c96d28c545867c39815b8",
"start_commit_sha": "e49b1fd335e093a440fcf35a21e050afd48ef932",
"created_time": 1658469499,
"updated_time": 1658469499
}
]
}
```
## 获取合并请求版本Diff
获取合并请求版本Diff(支持获取单文件Diff)
> 示例:
```shell
curl -X GET \
-d "filepath=ceshi_dir_1/new_file_1" \
http://localhost:3000/api/v1/yystopf/ceshi_commit/pulls/3/versions/33/diff.json
```
```javascript
await octokit.request('GET /api/v1/yystopf/ceshi_commit/pulls/3/versions/33/diff.json')
```
### HTTP 请求
`GET /api/v1/:owner/:repo/pulls/:index/versions/:version_id/diff.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|owner |是| |string |用户登录名 |
|repo |是| |string |项目标识identifier |
|index |是|| int |合并请求序号|
|version_id|是|| int |版本ID|
|filepath|否||string|文件路径|
### 列表返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|file_nums|int|文件数量|
|total_addition|int|新增行数|
|total_deletion|int|删除行数|
|files.name|string|文件名称|
|files.oldname|string|文件修改前名称|
|files.addition|int|文件新增行数|
|files.deletion|int|文件删除行数|
|files.type|int|文件类型 1: 新增 2: 更改 3: 删除 4: 重命名 5: 复制|
|files.is_created|bool|是否为新建文件|
|files.is_deleted|bool|是否为删除文件|
|files.is_bin|bool|是否为二进制文件|
|files.is_lfs_file|bool|是否为LFS文件|
|files.is_renamed|bool|是否重命名|
|files.is_ambiguous|bool||
|files.is_submodule|bool|是否为子模块|
|files.sections.file_name|string|文件名称|
|files.sections.name|string||
|files.sections.lines.left_index|int|文件变动之前所在行数|
|files.sections.lines.right_index|int|文件变动之后所在行数|
|files.sections.lines.match|int||
|files.sections.lines.type|int|文件变更类型|
|files.sections.lines.content|string|文件变更内容|
|files.sections.lines.section_path|string|文件路径|
|files.sections.lines.section_last_left_index|int||
|files.sections.lines.section_last_right_index|int||
|files.sections.lines.section_left_index|int|文件变更之前所在行数|
|files.sections.lines.section_right_index|int|文件变更之后所在行数(即:页面编辑器开始显示的行数)|
|files.sections.lines.section_left_hunk_size|int|文件变更之前的行数|
|files.sections.lines.section_right_hunk_size|int|文件变更之后的行数(及当前页面编辑器显示的总行数)|
|files.is_incomplete|bool|是否不完整|
|files.is_incomplete_line_too_long|bool|文件是否不完整是因为太长了|
|files.is_protected|bool|文件是否被保护|
> 列表返回的JSON示例:
```json
{
"file_nums": 29,
"total_addition": 5,
"total_deletion": 2,
"files": [
{
"name": "README.md",
"oldname": "README.md",
"addition": 1,
"deletion": 2,
"type": 2,
"is_created": false,
"is_deleted": false,
"is_bin": false,
"is_lfs_file": false,
"is_renamed": false,
"is_ambiguous": false,
"is_submodule": false,
"sections": [
{
"file_name": "README.md",
"name": "",
"lines": [
{
"left_index": 0,
"right_index": 0,
"match": 0,
"type": 4,
"content": "@@ -1,2 +1 @@",
"section_path": "README.md",
"section_last_left_index": 0,
"section_last_right_index": 0,
"section_left_index": 1,
"section_right_index": 1,
"section_left_hunk_size": 2,
"section_right_hunk_size": 0
},
{
"left_index": 1,
"right_index": 0,
"match": 3,
"type": 3,
"content": "-# ceshi_commit"
},
{
"left_index": 2,
"right_index": 0,
"match": -1,
"type": 3,
"content": "-"
},
{
"left_index": 0,
"right_index": 1,
"match": 1,
"type": 2,
"content": "+adsa"
}
]
},
{}
],
"is_incomplete": false,
"is_incomplete_line_too_long": false,
"is_protected": false
}
]
}
```
### 单个文件返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|name|string|文件名称|
|oldname|string|文件修改前名称|
|addition|int|文件新增行数|
|deletion|int|文件删除行数|
|type|int|文件类型 1: 新增 2: 更改 3: 删除 4: 重命名 5: 复制|
|is_created|bool|是否为新建文件|
|is_deleted|bool|是否为删除文件|
|is_bin|bool|是否为二进制文件|
|is_lfs_file|bool|是否为LFS文件|
|is_renamed|bool|是否重命名|
|is_ambiguous|bool||
|is_submodule|bool|是否为子模块|
|diff|string|git diff内容|
|sections.file_name|string|文件名称|
|sections.name|string||
|sections.lines.left_index|int|文件变动之前所在行数|
|sections.lines.right_index|int|文件变动之后所在行数|
|sections.lines.match|int||
|sections.lines.type|int|文件变更类型|
|sections.lines.content|string|文件变更内容|
|sections.lines.section_path|string|文件路径|
|sections.lines.section_last_left_index|int||
|sections.lines.section_last_right_index|int||
|sections.lines.section_left_index|int|文件变更之前所在行数|
|sections.lines.section_right_index|int|文件变更之后所在行数(即:页面编辑器开始显示的行数)|
|sections.lines.section_left_hunk_size|int|文件变更之前的行数|
|sections.lines.section_right_hunk_size|int|文件变更之后的行数(及当前页面编辑器显示的总行数)|
|is_incomplete|bool|是否不完整|
|is_incomplete_line_too_long|bool|文件是否不完整是因为太长了|
|is_protected|bool|文件是否被保护|
> 单个文件返回的JSON示例:
```json
{
"name": "README.md",
"oldname": "README.md",
"addition": 1,
"deletion": 2,
"type": 2,
"is_created": false,
"is_deleted": false,
"is_bin": false,
"is_lfs_file": false,
"is_renamed": false,
"is_ambiguous": false,
"is_submodule": false,
"sections": [
{
"file_name": "README.md",
"name": "",
"lines": [
{
"left_index": 0,
"right_index": 0,
"match": 0,
"type": 4,
"content": "@@ -1,2 +1 @@",
"section_path": "README.md",
"section_last_left_index": 0,
"section_last_right_index": 0,
"section_left_index": 1,
"section_right_index": 1,
"section_left_hunk_size": 2,
"section_right_hunk_size": 0
},
{
"left_index": 1,
"right_index": 0,
"match": 3,
"type": 3,
"content": "-# ceshi_commit"
},
{
"left_index": 2,
"right_index": 0,
"match": -1,
"type": 3,
"content": "-"
},
{
"left_index": 0,
"right_index": 1,
"match": 1,
"type": 2,
"content": "+adsa"
}
]
},
{
"file_name": "README.md",
"name": "",
"lines": [
{
"left_index": 0,
"right_index": 0,
"match": 0,
"type": 4,
"content": " ",
"section_path": "README.md",
"section_last_left_index": 0,
"section_last_right_index": 1,
"section_left_index": 3,
"section_right_index": 2,
"section_left_hunk_size": 0,
"section_right_hunk_size": 0
}
]
}
],
"is_incomplete": false,
"is_incomplete_line_too_long": false,
"is_protected": false
}
```
## 获取合并请求审查列表
获取合并请求版本审查列表
> 示例:
```shell
curl -X GET http://localhost:3000/api/v1/yystopf/ceshi_commit/pulls/3/reviews.json
```
```javascript
await octokit.request('GET /api/v1/yystopf/ceshi_commit/pulls/3/reviews.json')
```
### HTTP 请求
`GET /api/v1/:owner/:repo/pulls/:index/reviews.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|owner |是| |string |用户登录名 |
|repo |是| |string |项目标识identifier |
|index |是| | int |合并请求序号|
|status |否| |string |审查类型, common: 评论类型, approved: 已通过, rejected: 已拒绝|
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|total_count |int |审查总数|
|reviews.reviewer |object |审查者 |
|reviews.pull_request.id |integer|合并请求ID|
|reviews.pull_request.title |string|合并请求标题|
|reviews.pull_request.body |string|合并请求内容|
|reviews.pull_request.head |string|合并请求源分支|
|reviews.pull_request.base |string|合并请求目标分支|
|reviews.pull_request.is_original |string|合并请求是否从fork仓库所来|
|reviews.pull_request.fork_project.id |int|fork仓库的id|
|reviews.pull_request.fork_project.identifier|string|fork仓库的标识|
|reviews.pull_request.fork_project.login |string|fork仓库拥有者的标识|
|reviews.pull_request.index |string|合并请求的序号|
|reviews.pull_request.status |string|合并请求的状态,open: 打开的, merged: 合并的, closed: 关闭的|
|reviews.pull_request.issue.id |integer|合并请求下疑修的ID|
|reviews.pull_request.issue.author |object|合并请求以及疑修的创建着|
|reviews.pull_request.issue.priority |string|疑修的优先级|
|reviews.pull_request.issue.version |string|疑修的里程碑|
|reviews.pull_request.issue.journals_count|integer|普通评论数量|
|reviews.pull_request.issue.issue_tags |array|所属标记|
|reviews.pull_request.journals_count |integer|审查评论数量|
|reviews.id |integer|审查ID|
|reviews.commit_id |string|审查的commit ID|
|reviews.content |string|审查的内容|
|reviews.status |string|审查类型,common: 普通, approved: 通过,rejected: 拒绝通过|
|reviews.created_at |string|审查创建时间|
> 返回的JSON示例:
```json
{
"total_count": 1,
"reviews": [
{
"reviewer": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"pull_request": {
"id": 163,
"title": "新合并请求1",
"body": null,
"head": "master_1",
"base": "master",
"is_original": false,
"index": 1,
"status": "closed",
"issue": {
"id": 260,
"author": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"priority": null,
"version": null,
"journals_count": 0,
"issue_tags": null
},
"reviewers": [],
"journals_count": 8
},
"id": 5,
"commit_id": null,
"content": "新建一个审查",
"status": "common",
"created_at": "2022-07-25 17:08"
}
]
}
```
## 为合并请求创建一个审查
合并请求创建一个审查
> 示例:
```shell
curl -X POST \
http://localhost:3000/api/v1/yystopf/ceshi/pulls/1/reviews.json
```
```javascript
await octokit.request('POST /api/v1/yystopf/ceshi/pulls/1/reviews.json')
```
### HTTP 请求
`POST /api/v1/:owner/:repo/pulls/:index/reviews.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|owner |是| | string |用户登录名 |
|repo |是| | string |项目标识identifier |
|index |是| | integer|合并请求序号|
|content |否| | string |审查内容|
|commit_id |否| | string |当前合并请求的commit_id|
|status |是| | string |审查类型, common: 普通, approved: 通过, rejected: 拒绝|
> 请求的JSON示例:
```json
{
"content": "新建一个审查",
"commit_id": "e506844b2467ce25a35dd46dad8236a1595a02da",
"status": "common"
}
```
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|reviewer |object |审查者 |
|pull_request.id |integer|合并请求ID|
|pull_request.title |string|合并请求标题|
|pull_request.body |string|合并请求内容|
|pull_request.head |string|合并请求源分支|
|pull_request.base |string|合并请求目标分支|
|pull_request.is_original |string|合并请求是否从fork仓库所来|
|pull_request.fork_project.id |int|fork仓库的id|
|pull_request.fork_project.identifier|string|fork仓库的标识|
|pull_request.fork_project.login |string|fork仓库拥有者的标识|
|pull_request.index |string|合并请求的序号|
|pull_request.status |string|合并请求的状态,open: 打开的, merged: 合并的, closed: 关闭的|
|pull_request.issue.id |integer|合并请求下疑修的ID|
|pull_request.issue.author |object|合并请求以及疑修的创建着|
|pull_request.issue.priority |string|疑修的优先级|
|pull_request.issue.version |string|疑修的里程碑|
|pull_request.issue.journals_count|integer|普通评论数量|
|pull_request.issue.issue_tags |array|所属标记|
|pull_request.journals_count |integer|审查评论数量|
|id |integer|审查ID|
|commit_id |string|审查的commit ID|
|content |string|审查的内容|
|status |string|审查类型,common: 普通, approved: 通过,rejected: 拒绝通过|
|created_at |string|审查创建时间|
> 返回的JSON示例:
```json
{
"reviewer": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"pull_request": {
"id": 163,
"head": "master_1",
"base": "master",
"is_original": false,
"index": 1,
"status": "closed",
"issue": {
"id": 260,
"author": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"priority": null,
"version": null,
"journals_count": 0,
"issue_tags": null
},
"journals_count": 6
},
"id": 10,
"commit_id": "e506844b2467ce25a35dd46dad8236a1595a02da",
"content": "新建一个审查",
"status": "common",
"created_at": "2022-07-26 11:45"
}
```
## 获取合并请求评论列表
获取合并请求版本评论列表
> 示例:
```shell
curl -X GET http://localhost:3000/api/v1/yystopf/ceshi_commit/pulls/3/journals.json
```
```javascript
await octokit.request('GET /api/v1/yystopf/ceshi_commit/pulls/3/journals.json')
```
### HTTP 请求
`GET /api/v1/:owner/:repo/pulls/:index/journals.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|owner |是| |string |用户登录名 |
|repo |是| |string |项目标识identifier |
|index |是| | int |合并请求序号|
|keyword |否| |string |搜索关键词|
|review_id |否| |integer|审查ID|
|need_respond |否| |bool |是否需要回应|
|state |否| |string |状态, opened: 开启的, resolved: 已解决的, disabled: 无效的|
|parent_id |否| |integer|父评论ID|
|path |否| |string |评论文件路径|
|is_full |否| |bool |是否展示全部评论(包括回复)|
|sort_by |否|created_on|string |排序字段 created_on: 创建时间, updated_on: 更新时间|
|sort_direction |否|asc |string |排序类型 desc: 倒序, asc: 正序|
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|total_count |int |评论总数|
|journals.id |int |评论ID|
|journals.notes |string |评论内容|
|journals.commit_id |string |CommitID|
|journals.line_code |string |评论行数|
|journals.path |string |评论文件路径|
|journals.diff |object |评论文件diff内容|
|journals.need_respond |bool |评论是否要回应|
|journals.state |string |评论状态,opened: 开启的, resolved: 已解决的, disabled: 无效的 |
|journals.parent_id |int |父评论ID|
|journals.user |object |评论创建者|
|journals.review |object |评论所属评审|
|journals.resolveer |object |评论解决者|
|journals.resolve_at |int |评论解决时间|
|journals.created_at |int |评论创建时间|
|journals.updated_at |int |评论更新时间|
> 返回的JSON示例:
```json
{
"total_count": 1,
"journals": [
{
"id": 200,
"note": "测试评论修改",
"commit_id": null,
"line_code": "70eede447ccc01c1902260fd377af5d90be28e0d_0_29",
"path": "Gemfile.lock",
"diff": {},
"need_respond": true,
"state": "resolved",
"parent_id": nil,
"user": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"review": {
"reviewer": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"pull_request": {
"id": 163,
"title": "新合并请求1",
"body": null,
"head": "master_1",
"base": "master",
"is_original": false,
"index": 1,
"status": "closed",
"issue": {
"id": 260,
"author": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"priority": null,
"version": null,
"journals_count": 0,
"issue_tags": null
},
"reviewers": [],
"journals_count": 9
},
"id": 10,
"commit_id": "1",
"content": "新建一个审查",
"status": "common",
"created_at": "2022-07-26 11:45"
},
"resolveer": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"resolve_at": "2022-07-27 14:50",
"created_at": "2022-07-27 14:31",
"updated_at": "2022-07-27 14:50"
}
]
}
```
## 创建一个合并请求评论
为仓库创建一个合并请求的评论
> 示例:
```shell
curl -X POST \
http://localhost:3000/api/v1/yystopf/ceshi/pulls/1/journals.json
```
```javascript
await octokit.request('POST /api/v1/yystopf/ceshi/pulls/1/journals.json')
```
### HTTP 请求
`POST /api/v1/:owner/:repo/pulls/:index/journals.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|owner |是| | string |用户登录名 |
|repo |是| | string |项目标识identifier |
|index |是| | integer|合并请求序号|
|type |否|comment| string |评论类型 comment: 普通, problem: 需要回应的评论|
|note |否| | string |评论内容|
|review_id |否| | string |审查ID|
|line_code |否| | string |行号|
|commit_id |否| | bool |commitID|
|path |否| | integer|文件路径|
|parent_id |否| | integer|父评论ID|
|diff |否| | array |文件diff内容|
> 请求的JSON示例:
```json
{
"type": "problem",
"note": "测试评论",
"review_id": "10",
"line_code": "70eede447ccc01c1902260fd377af5d90be28e0d_0_29",
"commit_id": "70eede447ccc01c1902260fd377af5d90be28e0d",
"path": "Gemfile.lock",
"diff": {
"name": "README.md",
"oldname": "README.md",
"addition": 1,
"deletion": 2,
"type": 2,
"is_created": false,
"is_deleted": false,
"is_bin": false,
"is_lfs_file": false,
"is_renamed": false,
"is_ambiguous": false,
"is_submodule": false,
"sections": [
{
"file_name": "README.md",
"name": "",
"lines": [
{
"left_index": 0,
"right_index": 0,
"match": 0,
"type": 4,
"content": "@@ -1,2 +1 @@",
"section_path": "README.md",
"section_last_left_index": 0,
"section_last_right_index": 0,
"section_left_index": 1,
"section_right_index": 1,
"section_left_hunk_size": 2,
"section_right_hunk_size": 0
},
{
"left_index": 1,
"right_index": 0,
"match": 3,
"type": 3,
"content": "-# ceshi_commit"
},
{
"left_index": 2,
"right_index": 0,
"match": -1,
"type": 3,
"content": "-"
},
{
"left_index": 0,
"right_index": 1,
"match": 1,
"type": 2,
"content": "+adsa"
}
]
},
{
"file_name": "README.md",
"name": "",
"lines": [
{
"left_index": 0,
"right_index": 0,
"match": 0,
"type": 4,
"content": " ",
"section_path": "README.md",
"section_last_left_index": 0,
"section_last_right_index": 1,
"section_left_index": 3,
"section_right_index": 2,
"section_left_hunk_size": 0,
"section_right_hunk_size": 0
}
]
}
],
"is_incomplete": false,
"is_incomplete_line_too_long": false,
"is_protected": false
}
}
```
> 返回的JSON示例:
```json
{
"id": 200,
"note": "测试评论修改",
"commit_id": null,
"line_code": "70eede447ccc01c1902260fd377af5d90be28e0d_0_29",
"path": "Gemfile.lock",
"diff": {},
"need_respond": true,
"state": "resolved",
"user": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"review": {
"reviewer": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"pull_request": {
"id": 163,
"title": "新合并请求1",
"body": null,
"head": "master_1",
"base": "master",
"is_original": false,
"index": 1,
"status": "closed",
"issue": {
"id": 260,
"author": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"priority": null,
"version": null,
"journals_count": 0,
"issue_tags": null
},
"reviewers": [],
"journals_count": 9
},
"id": 10,
"commit_id": "1",
"content": "新建一个审查",
"status": "common",
"created_at": "2022-07-26 11:45"
},
"resolveer": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"resolve_at": "2022-07-27 14:50",
"created_at": "2022-07-27 14:31",
"updated_at": "2022-07-27 14:50"
}
```
## 修改一个合并请求评论
修改一个仓库合并请求的评论
> 示例:
```shell
curl -X PATCH \
http://localhost:3000/api/v1/yystopf/ceshi/pulls/1/journals/200.json
```
```javascript
await octokit.request('PATCH /api/v1/yystopf/ceshi/pulls/1/journals/200.json')
```
### HTTP 请求
`PATCH /api/v1/:owner/:repo/pulls/:index/journals/:id.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|owner |是| | string |用户登录名 |
|repo |是| | string |项目标识identifier |
|index |是| | integer|合并请求序号|
|id |是| | integer|评论ID|
|note |是| | string |评论内容|
|commit_id |是| | string |commitID|
|state |是| | string |评论状态, opened: 开启的, resolved: 已解决的, disabled: 无效的|
> 请求的JSON示例:
```json
{
"note": "测试评论",
"commit_id": "70eede447ccc01c1902260fd377af5d90be28e0d",
"state": "resolved"
}
```
> 返回的JSON示例:
```json
{
"id": 200,
"note": "测试评论修改",
"commit_id": null,
"line_code": "70eede447ccc01c1902260fd377af5d90be28e0d_0_29",
"path": "Gemfile.lock",
"diff": {},
"need_respond": true,
"state": "resolved",
"user": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"review": {
"reviewer": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"pull_request": {
"id": 163,
"title": "新合并请求1",
"body": null,
"head": "master_1",
"base": "master",
"is_original": false,
"index": 1,
"status": "closed",
"issue": {
"id": 260,
"author": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"priority": null,
"version": null,
"journals_count": 0,
"issue_tags": null
},
"reviewers": [],
"journals_count": 9
},
"id": 10,
"commit_id": "1",
"content": "新建一个审查",
"status": "common",
"created_at": "2022-07-26 11:45"
},
"resolveer": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"resolve_at": "2022-07-27 14:50",
"created_at": "2022-07-27 14:31",
"updated_at": "2022-07-27 14:50"
}
```
## 删除合并请求的一个评论
删除合并请求的一个评论
> 示例:
```shell
curl -X DELETE \
http://localhost:3000/api/v1/yystopf/ceshi/pulls/1/journals/200.json
```
```javascript
await octokit.request('DELETE /api/v1/yystopf/ceshi/pulls/1/journals/200.json')
```
### HTTP 请求
`DELETE /api/v1/:owner/:repo/pulls/:index/journals/:id.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|owner |是| | string |用户登录名 |
|repo |是| | string |项目标识identifier |
|index |是| | integer|合并请求序号|
|id |是| | integer|评论ID |
### 返回字段说明:
> 返回的JSON示例:
```json
{
"status": 0,
"message": "success"
}
```