新增: 获取比较blame、token以及异常捕获处理
This commit is contained in:
parent
e8deb83004
commit
6273349334
2
Gemfile
2
Gemfile
|
@ -135,4 +135,4 @@ gem 'doorkeeper'
|
|||
|
||||
gem 'doorkeeper-jwt'
|
||||
|
||||
gem 'gitea-client', '~> 0.9.3'
|
||||
gem 'gitea-client', '~> 0.9.4'
|
|
@ -3,6 +3,5 @@ class Api::V1::Projects::CommitsController < Api::V1::BaseController
|
|||
|
||||
def diff
|
||||
@result_object = Api::V1::Projects::Commits::DiffService.call(@project, params[:sha], current_user&.gitea_token)
|
||||
puts @result_object
|
||||
end
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
class Api::V1::ProjectsController < Api::V1::BaseController
|
||||
before_action :load_project, only: [:show]
|
||||
before_action :require_public_and_member_above, only: [:show, :compare]
|
||||
|
||||
def index
|
||||
render_ok
|
||||
|
@ -8,4 +8,8 @@ class Api::V1::ProjectsController < Api::V1::BaseController
|
|||
def show
|
||||
@result_object = Api::V1::Projects::GetService.call(@project, current_user.gitea_token)
|
||||
end
|
||||
|
||||
def compare
|
||||
@result_object = Api::V1::Projects::CompareService.call(@project, params[:from], params[:to], current_user&.gitea_token)
|
||||
end
|
||||
end
|
|
@ -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列表
|
||||
|
||||
|
|
|
@ -11,16 +11,20 @@ class Api::V1::Projects::Branches::AllListService < ApplicationService
|
|||
end
|
||||
|
||||
def call
|
||||
$gitea_client.token = token unless token.blank?
|
||||
load_gitea_data
|
||||
|
||||
$gitea_client.token = nil unless token.blank?
|
||||
gitea_data
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_client.get_repos_branch_name_set_by_owner_repo(owner, repo)
|
||||
@gitea_data = $gitea_client.get_repos_branch_name_set_by_owner_repo(owner, repo, {query: request_params}) rescue nil
|
||||
raise Error, '获取所有分支失败!' unless @gitea_data.is_a?(Hash)
|
||||
end
|
||||
end
|
|
@ -4,7 +4,7 @@ class Api::V1::Projects::Branches::CreateService < ApplicationService
|
|||
attr_accessor :project, :token, :owner, :repo, :old_branch_name, :new_branch_name
|
||||
attr_accessor :gitea_data
|
||||
|
||||
validates :new_branch_name, :old_branch_name, presence: :true
|
||||
validates :new_branch_name, :old_branch_name, presence: true
|
||||
|
||||
def initialize(project, params, token=nil)
|
||||
@project = project
|
||||
|
@ -17,16 +17,20 @@ class Api::V1::Projects::Branches::CreateService < ApplicationService
|
|||
|
||||
def call
|
||||
raise Error, errors.full_messages.join(",") unless valid?
|
||||
$gitea_client.token = token unless token.blank?
|
||||
|
||||
check_new_branch_exist
|
||||
excute_data_to_gitea
|
||||
|
||||
$gitea_client.token = nil unless token.blank?
|
||||
gitea_data
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def request_body
|
||||
{
|
||||
new_branch_name: new_branch_name,
|
||||
|
@ -35,12 +39,12 @@ class Api::V1::Projects::Branches::CreateService < ApplicationService
|
|||
end
|
||||
|
||||
def excute_data_to_gitea
|
||||
@gitea_data = $gitea_client.post_repos_branches_by_owner_repo(owner, repo, {body: request_body.to_json})
|
||||
@gitea_data = $gitea_client.post_repos_branches_by_owner_repo(owner, repo, {body: request_body.to_json, query: request_params}) rescue nil
|
||||
raise Error, '创建分支失败!' unless @gitea_data.is_a?(Hash)
|
||||
end
|
||||
|
||||
def check_new_branch_exist
|
||||
result = $gitea_client.get_repos_branch_name_set_by_owner_repo(owner, repo)
|
||||
result = $gitea_client.get_repos_branch_name_set_by_owner_repo(owner, repo) rescue nil
|
||||
raise Error, '查询分支名称失败!' unless result.is_a?(Hash)
|
||||
raise Error, '分支已存在!' if result['branch_name'].include?(@new_branch_name)
|
||||
end
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
class Api::V1::Projects::Commits::DiffService < ApplicationService
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_accessor :project, :sha, :token, :owner, :repo
|
||||
attr_accessor :gitea_data
|
||||
|
||||
validates :sha, presence: true
|
||||
|
||||
def initialize(project, sha, token = nil)
|
||||
@project = project
|
||||
@sha = sha
|
||||
|
@ -11,6 +15,7 @@ class Api::V1::Projects::Commits::DiffService < ApplicationService
|
|||
end
|
||||
|
||||
def call
|
||||
raise Error, errors.full_messages.join(",") unless valid?
|
||||
load_gitea_data
|
||||
|
||||
gitea_data
|
||||
|
@ -24,7 +29,7 @@ class Api::V1::Projects::Commits::DiffService < ApplicationService
|
|||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_client.get_repos_commits_diff_by_owner_repo_sha(owner, repo, sha, {query: request_params})
|
||||
@gitea_data = $gitea_client.get_repos_commits_diff_by_owner_repo_sha(owner, repo, sha, {query: request_params}) rescue nil
|
||||
raise Error, '获取提交对比失败!' unless @gitea_data.is_a?(Hash)
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
class Api::V1::Projects::CompareService < ApplicationService
|
||||
include ActiveModel::Model
|
||||
attr_reader :project, :from, :to, :token, :owner, :repo
|
||||
attr_accessor :gitea_data
|
||||
|
||||
validates :from, :to, presence: true
|
||||
|
||||
def initialize(project, from, to, token=nil)
|
||||
@project = project
|
||||
@owner = project&.owner.login
|
||||
@repo = project&.identifier
|
||||
@from = from
|
||||
@to = to
|
||||
@token = token
|
||||
end
|
||||
|
||||
def call
|
||||
raise Error, errors.full_messages.join(",") unless valid?
|
||||
load_gitea_data
|
||||
raise Error, '获取对比信息失败!' unless gitea_data.is_a?(Hash)
|
||||
gitea_data
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_client.get_repos_compare_by_owner_repo_from_to(owner, repo, from, to, {query: request_params}) rescue nil
|
||||
end
|
||||
end
|
|
@ -11,18 +11,20 @@ class Api::V1::Projects::GetService < ApplicationService
|
|||
end
|
||||
|
||||
def call
|
||||
$gitea_client.token = token unless token.blank?
|
||||
load_gitea_data
|
||||
load_gitea_branch_tag_count
|
||||
|
||||
$gitea_client.token = nil unless token.blank?
|
||||
|
||||
result_object
|
||||
rescue
|
||||
raise Error, "服务器错误,请联系系统管理员!"
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def result_object
|
||||
{
|
||||
|
@ -39,10 +41,10 @@ class Api::V1::Projects::GetService < ApplicationService
|
|||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_client.get_repos_by_owner_repo(owner, repo)
|
||||
@gitea_data = $gitea_client.get_repos_by_owner_repo(owner, repo, {query: request_params}) rescue nil
|
||||
end
|
||||
|
||||
def load_gitea_branch_tag_count
|
||||
@gitea_branch_tag_count = $gitea_client.get_repos_branch_tag_count_by_owner_repo(owner, repo)
|
||||
@gitea_branch_tag_count = $gitea_client.get_repos_branch_tag_count_by_owner_repo(owner, repo, {query: request_params}) rescue nil
|
||||
end
|
||||
end
|
|
@ -16,15 +16,19 @@ class Api::V1::Projects::Git::BlobsService < ApplicationService
|
|||
end
|
||||
|
||||
def call
|
||||
$gitea_client.token = token unless token.blank?
|
||||
load_gitea_data
|
||||
|
||||
$gitea_client.token = nil unless token.blank?
|
||||
gitea_data
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_client.get_repos_git_blobs_by_owner_repo_sha(owner, repo, sha)
|
||||
@gitea_data = $gitea_client.get_repos_git_blobs_by_owner_repo_sha(owner, repo, sha, {query: request_params}) rescue nil
|
||||
end
|
||||
end
|
|
@ -33,18 +33,20 @@ class Api::V1::Projects::Git::TreesService < ApplicationService
|
|||
{
|
||||
recursive: recursive,
|
||||
page: page,
|
||||
per_page: limit
|
||||
per_page: limit,
|
||||
access_token: token
|
||||
}
|
||||
else
|
||||
{
|
||||
page: page,
|
||||
per_page: limit
|
||||
per_page: limit,
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_client.get_repos_git_trees_by_owner_repo_sha(owner, repo, sha, {query: request_query})
|
||||
@gitea_data = $gitea_client.get_repos_git_trees_by_owner_repo_sha(owner, repo, sha, {query: request_query}) rescue nil
|
||||
raise Error, '获取文件树列表失败!' unless @gitea_data.is_a?(Hash)
|
||||
end
|
||||
end
|
|
@ -26,12 +26,8 @@ class Api::V1::Projects::Webhooks::CreateService < ApplicationService
|
|||
def call
|
||||
raise Error, errors.full_messages.join(",") unless valid?
|
||||
begin
|
||||
$gitea_client.token = token unless token.blank?
|
||||
|
||||
excute_data_to_gitea
|
||||
|
||||
$gitea_client.token = nil unless token.blank?
|
||||
|
||||
gitea_data
|
||||
rescue
|
||||
raise Error, "服务器错误,请联系系统管理员!"
|
||||
|
@ -39,6 +35,12 @@ class Api::V1::Projects::Webhooks::CreateService < ApplicationService
|
|||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def request_body
|
||||
{
|
||||
active: active,
|
||||
|
@ -55,6 +57,6 @@ class Api::V1::Projects::Webhooks::CreateService < ApplicationService
|
|||
end
|
||||
|
||||
def excute_data_to_gitea
|
||||
@gitea_data = $gitea_client.post_repos_hooks_by_owner_repo(owner, repo, {body: request_body.to_json})
|
||||
@gitea_data = $gitea_client.post_repos_hooks_by_owner_repo(owner, repo, {body: request_body.to_json, query: request_params}) rescue nil
|
||||
end
|
||||
end
|
|
@ -12,19 +12,21 @@ class Api::V1::Projects::Webhooks::DeleteService < ApplicationService
|
|||
end
|
||||
|
||||
def call
|
||||
$gitea_client.token = token unless token.blank?
|
||||
excute_data_to_gitea
|
||||
|
||||
$gitea_client.token = nil unless token.blank?
|
||||
|
||||
gitea_data
|
||||
rescue
|
||||
raise Error, "服务器错误,请联系系统管理员!"
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def excute_data_to_gitea
|
||||
@gitea_data = $gitea_client.delete_repos_hooks_by_owner_repo_id(owner, repo, id)
|
||||
@gitea_data = $gitea_client.delete_repos_hooks_by_owner_repo_id(owner, repo, id, {query: request_params}) rescue nil
|
||||
end
|
||||
end
|
|
@ -12,10 +12,8 @@ class Api::V1::Projects::Webhooks::GetService < ApplicationService
|
|||
end
|
||||
|
||||
def call
|
||||
$gitea_client.token = token unless token.blank?
|
||||
load_gitea_data
|
||||
|
||||
$gitea_client.token = nil unless token.blank?
|
||||
|
||||
gitea_data
|
||||
rescue
|
||||
|
@ -23,8 +21,13 @@ class Api::V1::Projects::Webhooks::GetService < ApplicationService
|
|||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_client.get_repos_hooks_by_owner_repo_id(owner, repo, id)
|
||||
@gitea_data = $gitea_client.get_repos_hooks_by_owner_repo_id(owner, repo, id, {query: request_params}) rescue nil
|
||||
end
|
||||
end
|
|
@ -23,8 +23,13 @@ class Api::V1::Projects::Webhooks::ListService < ApplicationService
|
|||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_client.get_repos_hooks_hooktasks_by_owner_repo(owner, repo, id)
|
||||
@gitea_data = $gitea_client.get_repos_hooks_hooktasks_by_owner_repo(owner, repo, id, {query: request_params}) rescue nil
|
||||
end
|
||||
end
|
|
@ -11,19 +11,21 @@ class Api::V1::Projects::Webhooks::ListService < ApplicationService
|
|||
end
|
||||
|
||||
def call
|
||||
$gitea_client.token = token unless token.blank?
|
||||
load_gitea_data
|
||||
|
||||
$gitea_client.token = nil unless token.blank?
|
||||
|
||||
gitea_data
|
||||
rescue
|
||||
raise Error, "服务器错误,请联系系统管理员!"
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_client.get_repos_hooks_by_owner_repo(owner, repo)
|
||||
@gitea_data = $gitea_client.get_repos_hooks_by_owner_repo(owner, repo, {query: request_params}) rescue nil
|
||||
end
|
||||
end
|
|
@ -12,19 +12,21 @@ class Api::V1::Projects::Webhooks::TestsService < ApplicationService
|
|||
end
|
||||
|
||||
def call
|
||||
$gitea_client.token = token unless token.blank?
|
||||
excute_data_to_gitea
|
||||
|
||||
$gitea_client.token = nil unless token.blank?
|
||||
|
||||
gitea_data
|
||||
rescue
|
||||
raise Error, "服务器错误,请联系系统管理员!"
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def excute_data_to_gitea
|
||||
@gitea_data = $gitea_client.post_repos_hooks_tests_by_owner_repo_id(owner, repo, id)
|
||||
@gitea_data = $gitea_client.post_repos_hooks_tests_by_owner_repo_id(owner, repo, id, {query: request_params}) rescue nil
|
||||
end
|
||||
end
|
|
@ -27,12 +27,8 @@ class Api::V1::Projects::Webhooks::UpdateService < ApplicationService
|
|||
def call
|
||||
raise Error, errors.full_messages.join(",") unless valid?
|
||||
begin
|
||||
$gitea_client.token = token unless token.blank?
|
||||
|
||||
excute_data_to_gitea
|
||||
|
||||
$gitea_client.token = nil unless token.blank?
|
||||
|
||||
gitea_data
|
||||
rescue
|
||||
raise Error, "服务器错误,请联系系统管理员!"
|
||||
|
@ -40,6 +36,12 @@ class Api::V1::Projects::Webhooks::UpdateService < ApplicationService
|
|||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def request_body
|
||||
{
|
||||
active: active,
|
||||
|
@ -56,6 +58,6 @@ class Api::V1::Projects::Webhooks::UpdateService < ApplicationService
|
|||
end
|
||||
|
||||
def excute_data_to_gitea
|
||||
@gitea_data = $gitea_client.patch_repos_hooks_by_owner_repo_id(owner, repo, id, {body: request_body.to_json})
|
||||
@gitea_data = $gitea_client.patch_repos_hooks_by_owner_repo_id(owner, repo, id, {body: request_body.to_json, query: request_params}) rescue nil
|
||||
end
|
||||
end
|
|
@ -0,0 +1,40 @@
|
|||
json.file_nums diff['NumFiles']
|
||||
json.total_addition diff['TotalAddition']
|
||||
json.total_deletion diff['TotalDeletion']
|
||||
json.files diff['Files'].each do |file|
|
||||
json.name file['Name']
|
||||
json.oldname file['OldName']
|
||||
json.addition file['Addition']
|
||||
json.deletion file['Deletion']
|
||||
json.type file['Type']
|
||||
json.is_created file['IsCreated']
|
||||
json.is_deleted file['IsDeleted']
|
||||
json.is_bin file['IsBin']
|
||||
json.is_lfs_file file['IsLFSFile']
|
||||
json.is_renamed file['IsRenamed']
|
||||
json.is_ambiguous file['IsAmbiguous']
|
||||
json.is_submodule file['IsSubmodule']
|
||||
json.sections file['Sections'] do |section|
|
||||
json.file_name section['FileName']
|
||||
json.name section['Name']
|
||||
json.lines section['Lines'] do |line|
|
||||
json.left_index line['LeftIdx']
|
||||
json.right_index line['RightIdx']
|
||||
json.match line['Match']
|
||||
json.type line['Type']
|
||||
json.content line['Content']
|
||||
unless line['SectionInfo'].blank?
|
||||
json.section_path line['SectionInfo']['Path']
|
||||
json.section_last_left_index line['SectionInfo']['LastLeftIdx']
|
||||
json.section_last_right_index line['SectionInfo']['LastRightIdx']
|
||||
json.section_left_index line['SectionInfo']['LeftIdx']
|
||||
json.section_right_index line['SectionInfo']['RightIdx']
|
||||
json.section_left_hunk_size line['SectionInfo']['LeftHunkSize']
|
||||
json.section_right_hunk_size line['SectionInfo']['RightHunkSize']
|
||||
end
|
||||
end
|
||||
end
|
||||
json.is_incomplete file['IsIncomplete']
|
||||
json.is_incomplete_line_too_long file['IsIncompleteLineTooLong']
|
||||
json.is_protected file['IsProtected']
|
||||
end
|
|
@ -1,40 +1 @@
|
|||
json.file_nums @result_object['NumFiles']
|
||||
json.total_addition @result_object['TotalAddition']
|
||||
json.total_deletion @result_object['TotalAddition']
|
||||
json.files @result_object['Files'].each do |file|
|
||||
json.name file['Name']
|
||||
json.oldname file['OldName']
|
||||
json.addition file['Addition']
|
||||
json.deletion file['Deletion']
|
||||
json.type file['Type']
|
||||
json.is_created file['IsCreated']
|
||||
json.is_deleted file['IsDeleted']
|
||||
json.is_bin file['IsBin']
|
||||
json.is_lfs_file file['IsLFSFile']
|
||||
json.is_renamed file['IsRenamed']
|
||||
json.is_ambiguous file['IsAmbiguous']
|
||||
json.is_submodule file['IsSubmodule']
|
||||
json.sections file['Sections'] do |section|
|
||||
json.file_name section['FileName']
|
||||
json.name section['Name']
|
||||
json.lines section['Lines'] do |line|
|
||||
json.left_index line['LeftIdx']
|
||||
json.right_index line['RightIdx']
|
||||
json.match line['Match']
|
||||
json.type line['Type']
|
||||
json.content line['Content']
|
||||
unless line['SectionInfo'].blank?
|
||||
json.section_path line['SectionInfo']['Path']
|
||||
json.section_last_left_index line['SectionInfo']['LastLeftIdx']
|
||||
json.section_last_right_index line['SectionInfo']['LastRightIdx']
|
||||
json.section_left_index line['SectionInfo']['LeftIdx']
|
||||
json.section_right_index line['SectionInfo']['RightIdx']
|
||||
json.section_left_hunk_size line['SectionInfo']['LeftHunkSize']
|
||||
json.section_right_hunk_size line['SectionInfo']['RightHunkSize']
|
||||
end
|
||||
end
|
||||
end
|
||||
json.is_incomplete file['IsIncomplete']
|
||||
json.is_incomplete_line_too_long file['IsIncompleteLineTooLong']
|
||||
json.is_protected file['IsProtected']
|
||||
end
|
||||
json.partial! "api/v1/projects/simple_gitea_diff_detail", diff: @result_object
|
|
@ -0,0 +1,18 @@
|
|||
json.commits_count @result_object['CommitsCount']
|
||||
json.last_commit_sha @result_object['LatestSha']
|
||||
json.commits @result_object['Commits'] do |commit|
|
||||
json.author do
|
||||
json.partial! 'api/v1/users/commit_user', locals: { user: render_cache_commit_author(commit['Author']), name: commit['Author']['Name'] }
|
||||
end
|
||||
|
||||
json.committer do
|
||||
json.partial! 'api/v1/users/commit_user', locals: { user: render_cache_commit_author(commit['Committer']), name: commit['Committer']['Name'] }
|
||||
end
|
||||
json.branch commit['Branch']
|
||||
json.commit_message commit['CommitMessage']
|
||||
json.sha commit['Sha']
|
||||
json.parent_shas commit['Sha']['ParentShas']
|
||||
end
|
||||
json.diff do
|
||||
json.partial! "api/v1/projects/simple_gitea_diff_detail", diff: @result_object['Diff']
|
||||
end
|
|
@ -9,7 +9,11 @@ defaults format: :json do
|
|||
|
||||
scope ':repo' do
|
||||
# projects
|
||||
resource :projects, path: '/', only: [:show, :update, :edit, :destroy]
|
||||
resource :projects, path: '/', only: [:show, :update, :edit, :destroy] do
|
||||
collection do
|
||||
get :compare
|
||||
end
|
||||
end
|
||||
|
||||
# projects文件夹下的
|
||||
scope module: :projects do
|
||||
|
|
|
@ -556,6 +556,9 @@
|
|||
<li>
|
||||
<a href="#blame" class="toc-h2 toc-link" data-title="获取单个提交的blame信息">获取单个提交的blame信息</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#blame-2" class="toc-h2 toc-link" data-title="获取比较提交blame">获取比较提交blame</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#webhooks" class="toc-h2 toc-link" data-title="获取仓库webhooks列表">获取仓库webhooks列表</a>
|
||||
</li>
|
||||
|
@ -9863,9 +9866,9 @@ http://localhost:3000/api/v1/yystopf/csfjkkj/git/trees/80dd40214a58622312393b2ae
|
|||
<p>返回的JSON示例:</p>
|
||||
</blockquote>
|
||||
<div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"file_nums"</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"total_addition"</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"total_deletion"</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"file_nums"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"total_addition"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"total_deletion"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"files"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"xinzeng3"</span><span class="p">,</span><span class="w">
|
||||
|
@ -9912,52 +9915,6 @@ http://localhost:3000/api/v1/yystopf/csfjkkj/git/trees/80dd40214a58622312393b2ae
|
|||
</span><span class="nl">"is_incomplete"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_incomplete_line_too_long"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_protected"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"xinzeng4"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"oldname"</span><span class="p">:</span><span class="w"> </span><span class="s2">"xinzeng4"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"addition"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"deletion"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_created"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_deleted"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_bin"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_lfs_file"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_renamed"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_ambiguous"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_submodule"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"sections"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"file_name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"xinzeng4"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">""</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"lines"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"left_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"right_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"match"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"content"</span><span class="p">:</span><span class="w"> </span><span class="s2">"@@ -0,0 +1 @@"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"section_path"</span><span class="p">:</span><span class="w"> </span><span class="s2">"xinzeng4"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"section_last_left_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"section_last_right_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"section_left_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"section_right_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"section_left_hunk_size"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"section_right_hunk_size"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"left_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"right_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"match"</span><span class="p">:</span><span class="w"> </span><span class="mi">-1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"content"</span><span class="p">:</span><span class="w"> </span><span class="s2">"+111112222"</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">],</span><span class="w">
|
||||
</span><span class="nl">"is_incomplete"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_incomplete_line_too_long"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_protected"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
|
@ -9965,17 +9922,19 @@ http://localhost:3000/api/v1/yystopf/csfjkkj/git/trees/80dd40214a58622312393b2ae
|
|||
<aside class="success">
|
||||
Success Data.
|
||||
</aside>
|
||||
<h2 id='webhooks'>获取仓库webhooks列表</h2>
|
||||
<p>获取仓库webhooks列表</p>
|
||||
<h2 id='blame-2'>获取比较提交blame</h2>
|
||||
<p>根据分支名、标签、commit ID来获取代码对比blame</p>
|
||||
|
||||
<blockquote>
|
||||
<p>示例:</p>
|
||||
</blockquote>
|
||||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span>
|
||||
http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
|
||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/v1/yystopf/ceshi/webhooks.json</span><span class="dl">'</span><span class="p">)</span>
|
||||
<span class="nt">-d</span> <span class="s2">"from=hh_ceshi"</span> <span class="se">\</span>
|
||||
<span class="nt">-d</span> <span class="s2">"to=master"</span> <span class="se">\</span>
|
||||
http://localhost:3000/api/v1/yystopf/csfjkkj/compare.json
|
||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/v1/yystopf/csfjkkj/compare.json</span><span class="dl">'</span><span class="p">)</span>
|
||||
</code></pre></div><h3 id='http-23'>HTTP 请求</h3>
|
||||
<p><code>GET /api/v1/:owner/:repo/webhooks.json</code></p>
|
||||
<p><code>GET /api/v1/:owner/:repo/compare.json</code></p>
|
||||
<h3 id='2eb6f47757-23'>请求参数:</h3>
|
||||
<table><thead>
|
||||
<tr>
|
||||
|
@ -10000,6 +9959,20 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
|
|||
<td>string</td>
|
||||
<td>项目标识identifier</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>from</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>源分支、标签、commitID</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>to</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>目标分支、标签、commitID</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
<h3 id='7447e4874e-23'>返回字段说明:</h3>
|
||||
<table><thead>
|
||||
|
@ -10010,6 +9983,318 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
|
|||
</tr>
|
||||
</thead><tbody>
|
||||
<tr>
|
||||
<td>commits_count</td>
|
||||
<td>int</td>
|
||||
<td>提交数量</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>commits.branch</td>
|
||||
<td>string</td>
|
||||
<td>提交分支</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>commits.author</td>
|
||||
<td>object</td>
|
||||
<td>提交作者</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>commits.committer</td>
|
||||
<td>object</td>
|
||||
<td>提交者</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>commits.commit_message</td>
|
||||
<td>string</td>
|
||||
<td>提交信息</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>commits.sha</td>
|
||||
<td>string</td>
|
||||
<td>提交ID</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>commits.parent_shas</td>
|
||||
<td>array</td>
|
||||
<td>提交父节点ID</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.file_nums</td>
|
||||
<td>int</td>
|
||||
<td>文件数量</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.total_addition</td>
|
||||
<td>int</td>
|
||||
<td>新增行数</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.total_deletion</td>
|
||||
<td>int</td>
|
||||
<td>删除行数</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.name</td>
|
||||
<td>string</td>
|
||||
<td>文件名称</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.oldname</td>
|
||||
<td>string</td>
|
||||
<td>文件修改前名称</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.addition</td>
|
||||
<td>int</td>
|
||||
<td>文件新增行数</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.deletion</td>
|
||||
<td>int</td>
|
||||
<td>文件删除行数</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.type</td>
|
||||
<td>int</td>
|
||||
<td>文件类型 1: 新增 2: 更改 3: 删除 4: 重命名 5: 复制</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.is_created</td>
|
||||
<td>bool</td>
|
||||
<td>是否为新建文件</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.is_deleted</td>
|
||||
<td>bool</td>
|
||||
<td>是否为删除文件</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.is_bin</td>
|
||||
<td>bool</td>
|
||||
<td>是否为二进制文件</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.is_lfs_file</td>
|
||||
<td>bool</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.is_renamed</td>
|
||||
<td>bool</td>
|
||||
<td>是否重命名</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.is_ambiguous</td>
|
||||
<td>bool</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.is_submodule</td>
|
||||
<td>bool</td>
|
||||
<td>是否为子模块</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.sections.file_name</td>
|
||||
<td>string</td>
|
||||
<td>文件名称</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.sections.name</td>
|
||||
<td>string</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.sections.lines.left_index</td>
|
||||
<td>int</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.sections.lines.right_index</td>
|
||||
<td>int</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.sections.lines.match</td>
|
||||
<td>int</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.sections.lines.type</td>
|
||||
<td>int</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.sections.lines.content</td>
|
||||
<td>string</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.sections.lines.section_path</td>
|
||||
<td>string</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.sections.lines.section_last_left_index</td>
|
||||
<td>int</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.sections.lines.section_last_right_index</td>
|
||||
<td>int</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.sections.lines.section_left_index</td>
|
||||
<td>int</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.sections.lines.section_right_index</td>
|
||||
<td>int</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.sections.lines.section_left_hunk_size</td>
|
||||
<td>int</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff.files.sections.lines.section_right_hunk_size</td>
|
||||
<td>int</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
|
||||
<blockquote>
|
||||
<p>返回的JSON示例:</p>
|
||||
</blockquote>
|
||||
<div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"commits_count"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"last_commit_sha"</span><span class="p">:</span><span class="w"> </span><span class="s2">"80dd40214a58622312393b2ae693756a4781fab2"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"commits"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"author"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"yystopf"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"heh"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"User"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"system/lets/letter_avatars/2/H/188_239_142/120.png"</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="nl">"committer"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"yystopf"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"heh"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"User"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"system/lets/letter_avatars/2/H/188_239_142/120.png"</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="nl">"branch"</span><span class="p">:</span><span class="w"> </span><span class="s2">""</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"commit_message"</span><span class="p">:</span><span class="w"> </span><span class="s2">"x拟增</span><span class="se">\n\n</span><span class="s2">Signed-off-by: yystopf <yystopf@163.com>"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"sha"</span><span class="p">:</span><span class="w"> </span><span class="s2">"7e4d8bb3c28e24d4cd6b205f2eed32513e937524"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"parent_shas"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">],</span><span class="w">
|
||||
</span><span class="nl">"diff"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"file_nums"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"total_addition"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"total_deletion"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"files"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ceshi123"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"oldname"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ceshi123"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"addition"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"deletion"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_created"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_deleted"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_bin"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_lfs_file"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_renamed"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_ambiguous"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_submodule"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"sections"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"file_name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ceshi123"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">""</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"lines"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"left_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"right_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"match"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"content"</span><span class="p">:</span><span class="w"> </span><span class="s2">"@@ -0,0 +1 @@"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"section_path"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ceshi123"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"section_last_left_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"section_last_right_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"section_left_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"section_right_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"section_left_hunk_size"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"section_right_hunk_size"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"left_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"right_index"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"match"</span><span class="p">:</span><span class="w"> </span><span class="mi">-1</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"content"</span><span class="p">:</span><span class="w"> </span><span class="s2">"+1111122222"</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">],</span><span class="w">
|
||||
</span><span class="nl">"is_incomplete"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_incomplete_line_too_long"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"is_protected"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span></code></pre></div>
|
||||
<aside class="success">
|
||||
Success Data.
|
||||
</aside>
|
||||
<h2 id='webhooks'>获取仓库webhooks列表</h2>
|
||||
<p>获取仓库webhooks列表</p>
|
||||
|
||||
<blockquote>
|
||||
<p>示例:</p>
|
||||
</blockquote>
|
||||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span>
|
||||
http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
|
||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/v1/yystopf/ceshi/webhooks.json</span><span class="dl">'</span><span class="p">)</span>
|
||||
</code></pre></div><h3 id='http-24'>HTTP 请求</h3>
|
||||
<p><code>GET /api/v1/:owner/:repo/webhooks.json</code></p>
|
||||
<h3 id='2eb6f47757-24'>请求参数:</h3>
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
<th>必选</th>
|
||||
<th>默认</th>
|
||||
<th>类型</th>
|
||||
<th>字段说明</th>
|
||||
</tr>
|
||||
</thead><tbody>
|
||||
<tr>
|
||||
<td>owner</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>用户登录名</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>repo</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>项目标识identifier</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
<h3 id='7447e4874e-24'>返回字段说明:</h3>
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
<th>类型</th>
|
||||
<th>字段说明</th>
|
||||
</tr>
|
||||
</thead><tbody>
|
||||
<tr>
|
||||
<td>id</td>
|
||||
<td>int</td>
|
||||
<td>id</td>
|
||||
|
@ -10094,9 +10379,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
|
|||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span>
|
||||
http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3.json
|
||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/v1/yystopf/ceshi/webhooks/3.json</span><span class="dl">'</span><span class="p">)</span>
|
||||
</code></pre></div><h3 id='http-24'>HTTP 请求</h3>
|
||||
</code></pre></div><h3 id='http-25'>HTTP 请求</h3>
|
||||
<p><code>GET /api/v1/:owner/:repo/webhooks/:id.json</code></p>
|
||||
<h3 id='2eb6f47757-24'>请求参数:</h3>
|
||||
<h3 id='2eb6f47757-25'>请求参数:</h3>
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
|
@ -10128,7 +10413,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3.json
|
|||
<td>webhook ID</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
<h3 id='7447e4874e-24'>返回字段说明:</h3>
|
||||
<h3 id='7447e4874e-25'>返回字段说明:</h3>
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
|
@ -10251,214 +10536,8 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3.json
|
|||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST <span class="se">\</span>
|
||||
http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
|
||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">POST /api/v1/yystopf/ceshi/webhooks.json</span><span class="dl">'</span><span class="p">)</span>
|
||||
</code></pre></div><h3 id='http-25'>HTTP 请求</h3>
|
||||
<p><code>POST /api/v1/:owner/:repo/webhooks.json</code></p>
|
||||
<h3 id='2eb6f47757-25'>请求参数:</h3>
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
<th>必选</th>
|
||||
<th>默认</th>
|
||||
<th>类型</th>
|
||||
<th>字段说明</th>
|
||||
</tr>
|
||||
</thead><tbody>
|
||||
<tr>
|
||||
<td>owner</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>用户登录名</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>repo</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>项目标识identifier</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.url</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>目标url</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.http_method</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>http方法, POST和GET</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.content_type</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>POST Content Type</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.secret</td>
|
||||
<td>否</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>密钥文本</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.active</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>bool</td>
|
||||
<td>是否激活</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.branch_filter</td>
|
||||
<td>否</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>分支过滤</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.events</td>
|
||||
<td>否</td>
|
||||
<td></td>
|
||||
<td>array</td>
|
||||
<td>触发事件</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
|
||||
<p>触发事件字段说明 </p>
|
||||
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
<th>含义</th>
|
||||
</tr>
|
||||
</thead><tbody>
|
||||
<tr>
|
||||
<td>create</td>
|
||||
<td>创建分支或标签</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>delete</td>
|
||||
<td>分支或标签删除</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>push</td>
|
||||
<td>git仓库推送</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>pull_request</td>
|
||||
<td>合并请求</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>pull_request_assign</td>
|
||||
<td>合并请求被指派</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>pull_request_review_approved</td>
|
||||
<td>合并请求被批准</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>pull_request_review_rejected</td>
|
||||
<td>合并请求被拒绝</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
|
||||
<blockquote>
|
||||
<p>请求的JSON示例:</p>
|
||||
</blockquote>
|
||||
<div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"active"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"content_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"json"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"http_method"</span><span class="p">:</span><span class="w"> </span><span class="s2">"GET"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"secret"</span><span class="p">:</span><span class="w"> </span><span class="s2">"123456"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"http://localhost:10000"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"branch_filter"</span><span class="p">:</span><span class="w"> </span><span class="s2">"*"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"events"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"push"</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span></code></pre></div><h3 id='7447e4874e-25'>返回字段说明:</h3>
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
<th>类型</th>
|
||||
<th>字段说明</th>
|
||||
</tr>
|
||||
</thead><tbody>
|
||||
<tr>
|
||||
<td>id</td>
|
||||
<td>int</td>
|
||||
<td>id</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>url</td>
|
||||
<td>string</td>
|
||||
<td>地址</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>content_type</td>
|
||||
<td>string</td>
|
||||
<td>POST Content Type</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>is_active</td>
|
||||
<td>bool</td>
|
||||
<td>是否激活</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>type</td>
|
||||
<td>string</td>
|
||||
<td>类型</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>events</td>
|
||||
<td>array</td>
|
||||
<td>触发事件</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>create_time</td>
|
||||
<td>string</td>
|
||||
<td>创建时间</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
|
||||
<blockquote>
|
||||
<p>返回的JSON示例:</p>
|
||||
</blockquote>
|
||||
<div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">68</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"content_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"json"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"http_method"</span><span class="p">:</span><span class="w"> </span><span class="s2">"GET"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"http://127.0.0.1:3000"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"events"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="s2">"create"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="s2">"delete"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="s2">"push"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="s2">"pull_request"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="s2">"pull_request_assign"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="s2">"pull_request_review_approved"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="s2">"pull_request_review_rejected"</span><span class="w">
|
||||
</span><span class="p">],</span><span class="w">
|
||||
</span><span class="nl">"active"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"branch_filter"</span><span class="p">:</span><span class="w"> </span><span class="s2">"*"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"created_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2022-06-23 15:52"</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span></code></pre></div>
|
||||
<aside class="success">
|
||||
Success Data.
|
||||
</aside>
|
||||
<h2 id='webhook-3'>更新仓库webhook</h2>
|
||||
<p>更新仓库webhook</p>
|
||||
|
||||
<blockquote>
|
||||
<p>示例:</p>
|
||||
</blockquote>
|
||||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> PATCH <span class="se">\</span>
|
||||
http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
|
||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">PATCH /api/v1/yystopf/ceshi/webhooks/7.json</span><span class="dl">'</span><span class="p">)</span>
|
||||
</code></pre></div><h3 id='http-26'>HTTP 请求</h3>
|
||||
<p><code>PATCH /api/v1/:owner/:repo/webhooks/68.json</code></p>
|
||||
<p><code>POST /api/v1/:owner/:repo/webhooks.json</code></p>
|
||||
<h3 id='2eb6f47757-26'>请求参数:</h3>
|
||||
<table><thead>
|
||||
<tr>
|
||||
|
@ -10484,13 +10563,6 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
|
|||
<td>项目标识identifier</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>id</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>webhook id</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.url</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
|
@ -10592,6 +10664,219 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
|
|||
</span><span class="nl">"events"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"push"</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span></code></pre></div><h3 id='7447e4874e-26'>返回字段说明:</h3>
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
<th>类型</th>
|
||||
<th>字段说明</th>
|
||||
</tr>
|
||||
</thead><tbody>
|
||||
<tr>
|
||||
<td>id</td>
|
||||
<td>int</td>
|
||||
<td>id</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>url</td>
|
||||
<td>string</td>
|
||||
<td>地址</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>content_type</td>
|
||||
<td>string</td>
|
||||
<td>POST Content Type</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>is_active</td>
|
||||
<td>bool</td>
|
||||
<td>是否激活</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>type</td>
|
||||
<td>string</td>
|
||||
<td>类型</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>events</td>
|
||||
<td>array</td>
|
||||
<td>触发事件</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>create_time</td>
|
||||
<td>string</td>
|
||||
<td>创建时间</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
|
||||
<blockquote>
|
||||
<p>返回的JSON示例:</p>
|
||||
</blockquote>
|
||||
<div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">68</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"content_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"json"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"http_method"</span><span class="p">:</span><span class="w"> </span><span class="s2">"GET"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"http://127.0.0.1:3000"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"events"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="s2">"create"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="s2">"delete"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="s2">"push"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="s2">"pull_request"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="s2">"pull_request_assign"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="s2">"pull_request_review_approved"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="s2">"pull_request_review_rejected"</span><span class="w">
|
||||
</span><span class="p">],</span><span class="w">
|
||||
</span><span class="nl">"active"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"branch_filter"</span><span class="p">:</span><span class="w"> </span><span class="s2">"*"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"created_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2022-06-23 15:52"</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span></code></pre></div>
|
||||
<aside class="success">
|
||||
Success Data.
|
||||
</aside>
|
||||
<h2 id='webhook-3'>更新仓库webhook</h2>
|
||||
<p>更新仓库webhook</p>
|
||||
|
||||
<blockquote>
|
||||
<p>示例:</p>
|
||||
</blockquote>
|
||||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> PATCH <span class="se">\</span>
|
||||
http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
|
||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">PATCH /api/v1/yystopf/ceshi/webhooks/7.json</span><span class="dl">'</span><span class="p">)</span>
|
||||
</code></pre></div><h3 id='http-27'>HTTP 请求</h3>
|
||||
<p><code>PATCH /api/v1/:owner/:repo/webhooks/68.json</code></p>
|
||||
<h3 id='2eb6f47757-27'>请求参数:</h3>
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
<th>必选</th>
|
||||
<th>默认</th>
|
||||
<th>类型</th>
|
||||
<th>字段说明</th>
|
||||
</tr>
|
||||
</thead><tbody>
|
||||
<tr>
|
||||
<td>owner</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>用户登录名</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>repo</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>项目标识identifier</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>id</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>webhook id</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.url</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>目标url</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.http_method</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>http方法, POST和GET</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.content_type</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>POST Content Type</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.secret</td>
|
||||
<td>否</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>密钥文本</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.active</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>bool</td>
|
||||
<td>是否激活</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.branch_filter</td>
|
||||
<td>否</td>
|
||||
<td></td>
|
||||
<td>string</td>
|
||||
<td>分支过滤</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.events</td>
|
||||
<td>否</td>
|
||||
<td></td>
|
||||
<td>array</td>
|
||||
<td>触发事件</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
|
||||
<p>触发事件字段说明 </p>
|
||||
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
<th>含义</th>
|
||||
</tr>
|
||||
</thead><tbody>
|
||||
<tr>
|
||||
<td>create</td>
|
||||
<td>创建分支或标签</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>delete</td>
|
||||
<td>分支或标签删除</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>push</td>
|
||||
<td>git仓库推送</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>pull_request</td>
|
||||
<td>合并请求</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>pull_request_assign</td>
|
||||
<td>合并请求被指派</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>pull_request_review_approved</td>
|
||||
<td>合并请求被批准</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>pull_request_review_rejected</td>
|
||||
<td>合并请求被拒绝</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
|
||||
<blockquote>
|
||||
<p>请求的JSON示例:</p>
|
||||
</blockquote>
|
||||
<div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"active"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"content_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"json"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"http_method"</span><span class="p">:</span><span class="w"> </span><span class="s2">"GET"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"secret"</span><span class="p">:</span><span class="w"> </span><span class="s2">"123456"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"http://localhost:10000"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"branch_filter"</span><span class="p">:</span><span class="w"> </span><span class="s2">"*"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"events"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"push"</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span></code></pre></div><h3 id='7447e4874e-27'>返回字段说明:</h3>
|
||||
<blockquote>
|
||||
<p>返回的JSON示例:</p>
|
||||
</blockquote>
|
||||
|
@ -10626,9 +10911,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
|
|||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> DELETE <span class="se">\</span>
|
||||
http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
|
||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">DELETE /api/v1/yystopf/ceshi/webhooks/7.json</span><span class="dl">'</span><span class="p">)</span>
|
||||
</code></pre></div><h3 id='http-27'>HTTP 请求</h3>
|
||||
</code></pre></div><h3 id='http-28'>HTTP 请求</h3>
|
||||
<p><code>DELETE /api/v1/:owner/:repo/webhooks/:id.json</code></p>
|
||||
<h3 id='2eb6f47757-27'>请求参数:</h3>
|
||||
<h3 id='2eb6f47757-28'>请求参数:</h3>
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
|
@ -10660,7 +10945,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
|
|||
<td>webhook id</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
<h3 id='7447e4874e-27'>返回字段说明:</h3>
|
||||
<h3 id='7447e4874e-28'>返回字段说明:</h3>
|
||||
<blockquote>
|
||||
<p>返回的JSON示例:</p>
|
||||
</blockquote>
|
||||
|
@ -10681,9 +10966,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
|
|||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span>
|
||||
http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/hooktasks.json
|
||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/v1/yystopf/ceshi/webhooks/3/hooktasks.json</span><span class="dl">'</span><span class="p">)</span>
|
||||
</code></pre></div><h3 id='http-28'>HTTP 请求</h3>
|
||||
</code></pre></div><h3 id='http-29'>HTTP 请求</h3>
|
||||
<p><code>GET /api/v1/:owner/:repo/webhooks/:id/hooktasks.json</code></p>
|
||||
<h3 id='2eb6f47757-28'>请求参数:</h3>
|
||||
<h3 id='2eb6f47757-29'>请求参数:</h3>
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
|
@ -10715,7 +11000,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/hooktasks.json
|
|||
<td>webhook ID</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
<h3 id='7447e4874e-28'>返回字段说明:</h3>
|
||||
<h3 id='7447e4874e-29'>返回字段说明:</h3>
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
|
@ -10952,9 +11237,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/hooktasks.json
|
|||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST <span class="se">\</span>
|
||||
http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/tests.json
|
||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">POST /api/v1/yystopf/ceshi/webhooks/3/tests.json</span><span class="dl">'</span><span class="p">)</span>
|
||||
</code></pre></div><h3 id='http-29'>HTTP 请求</h3>
|
||||
</code></pre></div><h3 id='http-30'>HTTP 请求</h3>
|
||||
<p><code>POST /api/v1/:owner/:repo/webhooks/:id/tests.json</code></p>
|
||||
<h3 id='2eb6f47757-29'>请求参数:</h3>
|
||||
<h3 id='2eb6f47757-30'>请求参数:</h3>
|
||||
<table><thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
|
@ -10986,7 +11271,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/tests.json
|
|||
<td>webhook ID</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
<h3 id='7447e4874e-29'>返回字段说明:</h3>
|
||||
<h3 id='7447e4874e-30'>返回字段说明:</h3>
|
||||
<blockquote>
|
||||
<p>返回的JSON示例:</p>
|
||||
</blockquote>
|
||||
|
|
Loading…
Reference in New Issue