新增: 获取比较blame、token以及异常捕获处理

This commit is contained in:
2022-07-18 11:37:41 +08:00
parent e8deb83004
commit 6273349334
23 changed files with 912 additions and 419 deletions

View File

@@ -1474,9 +1474,9 @@ await octokit.request('GET /api/v1/yystopf/csfjkkj/commits/80dd40214a58622312393
```json
{
"file_nums": 2,
"total_addition": 2,
"total_deletion": 2,
"file_nums": 1,
"total_addition": 1,
"total_deletion": 0,
"files": [
{
"name": "xinzeng3",
@@ -1523,52 +1523,6 @@ await octokit.request('GET /api/v1/yystopf/csfjkkj/commits/80dd40214a58622312393
"is_incomplete": false,
"is_incomplete_line_too_long": false,
"is_protected": false
},
{
"name": "xinzeng4",
"oldname": "xinzeng4",
"addition": 1,
"deletion": 0,
"type": 1,
"is_created": true,
"is_deleted": false,
"is_bin": false,
"is_lfs_file": false,
"is_renamed": false,
"is_ambiguous": false,
"is_submodule": false,
"sections": [
{
"file_name": "xinzeng4",
"name": "",
"lines": [
{
"left_index": 0,
"right_index": 0,
"match": 0,
"type": 4,
"content": "@@ -0,0 +1 @@",
"section_path": "xinzeng4",
"section_last_left_index": 0,
"section_last_right_index": 0,
"section_left_index": 0,
"section_right_index": 1,
"section_left_hunk_size": 0,
"section_right_hunk_size": 0
},
{
"left_index": 0,
"right_index": 1,
"match": -1,
"type": 2,
"content": "+111112222"
}
]
}
],
"is_incomplete": false,
"is_incomplete_line_too_long": false,
"is_protected": false
}
]
}
@@ -1577,6 +1531,161 @@ await octokit.request('GET /api/v1/yystopf/csfjkkj/commits/80dd40214a58622312393
Success Data.
</aside>
## 获取比较提交blame
根据分支名、标签、commit ID来获取代码对比blame
> 示例:
```shell
curl -X GET \
-d "from=hh_ceshi" \
-d "to=master" \
http://localhost:3000/api/v1/yystopf/csfjkkj/compare.json
```
```javascript
await octokit.request('GET /api/v1/yystopf/csfjkkj/compare.json')
```
### HTTP 请求
`GET /api/v1/:owner/:repo/compare.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|owner|是| | string |用户登录名 |
|repo |是| | string |项目标识identifier |
|from |是| | string |源分支、标签、commitID |
|to|是||string|目标分支、标签、commitID|
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|commits_count|int|提交数量|
|commits.branch|string|提交分支|
|commits.author|object|提交作者|
|commits.committer|object|提交者|
|commits.commit_message|string|提交信息|
|commits.sha|string|提交ID|
|commits.parent_shas|array|提交父节点ID|
|diff.file_nums|int|文件数量|
|diff.total_addition|int|新增行数|
|diff.total_deletion|int|删除行数|
|diff.files.name|string|文件名称|
|diff.files.oldname|string|文件修改前名称|
|diff.files.addition|int|文件新增行数|
|diff.files.deletion|int|文件删除行数|
|diff.files.type|int|文件类型 1: 新增 2: 更改 3: 删除 4: 重命名 5: 复制|
|diff.files.is_created|bool|是否为新建文件|
|diff.files.is_deleted|bool|是否为删除文件|
|diff.files.is_bin|bool|是否为二进制文件|
|diff.files.is_lfs_file|bool||
|diff.files.is_renamed|bool|是否重命名|
|diff.files.is_ambiguous|bool||
|diff.files.is_submodule|bool|是否为子模块|
|diff.files.sections.file_name|string|文件名称|
|diff.files.sections.name|string||
|diff.files.sections.lines.left_index|int||
|diff.files.sections.lines.right_index|int||
|diff.files.sections.lines.match|int||
|diff.files.sections.lines.type|int||
|diff.files.sections.lines.content|string||
|diff.files.sections.lines.section_path|string||
|diff.files.sections.lines.section_last_left_index|int||
|diff.files.sections.lines.section_last_right_index|int||
|diff.files.sections.lines.section_left_index|int||
|diff.files.sections.lines.section_right_index|int||
|diff.files.sections.lines.section_left_hunk_size|int||
|diff.files.sections.lines.section_right_hunk_size|int||
> 返回的JSON示例:
```json
{
"commits_count": 1,
"last_commit_sha": "80dd40214a58622312393b2ae693756a4781fab2",
"commits": [
{
"author": {
"id": "2",
"login": "yystopf",
"name": "heh",
"type": "User",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"committer": {
"id": "2",
"login": "yystopf",
"name": "heh",
"type": "User",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"branch": "",
"commit_message": "x拟增\n\nSigned-off-by: yystopf <yystopf@163.com>",
"sha": "7e4d8bb3c28e24d4cd6b205f2eed32513e937524",
"parent_shas": null
}
],
"diff": {
"file_nums": 1,
"total_addition": 1,
"total_deletion": 0,
"files": [
{
"name": "ceshi123",
"oldname": "ceshi123",
"addition": 1,
"deletion": 0,
"type": 1,
"is_created": true,
"is_deleted": false,
"is_bin": false,
"is_lfs_file": false,
"is_renamed": false,
"is_ambiguous": false,
"is_submodule": false,
"sections": [
{
"file_name": "ceshi123",
"name": "",
"lines": [
{
"left_index": 0,
"right_index": 0,
"match": 0,
"type": 4,
"content": "@@ -0,0 +1 @@",
"section_path": "ceshi123",
"section_last_left_index": 0,
"section_last_right_index": 0,
"section_left_index": 0,
"section_right_index": 1,
"section_left_hunk_size": 0,
"section_right_hunk_size": 0
},
{
"left_index": 0,
"right_index": 1,
"match": -1,
"type": 2,
"content": "+1111122222"
}
]
}
],
"is_incomplete": false,
"is_incomplete_line_too_long": false,
"is_protected": false
}
]
}
}
```
<aside class="success">
Success Data.
</aside>
## 获取仓库webhooks列表
获取仓库webhooks列表