diff --git a/app/controllers/api/v1/projects/branches_controller.rb b/app/controllers/api/v1/projects/branches_controller.rb index d7f66d749..bc4919616 100644 --- a/app/controllers/api/v1/projects/branches_controller.rb +++ b/app/controllers/api/v1/projects/branches_controller.rb @@ -1,5 +1,5 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController - before_action :require_public_and_member_above, only: [:index] + before_action :require_public_and_member_above, only: [:all] def all @result_object = Api::V1::Projects::Branches::AllListService.call(@project, current_user&.gitea_token) @@ -9,7 +9,6 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController def create @result_object = Api::V1::Projects::Branches::CreateService.call(@project, branch_params, current_user&.gitea_token) - puts @result_object end private diff --git a/app/docs/slate/source/includes/_repositories.md b/app/docs/slate/source/includes/_repositories.md index f0a64a60d..624afd5b1 100644 --- a/app/docs/slate/source/includes/_repositories.md +++ b/app/docs/slate/source/includes/_repositories.md @@ -409,21 +409,21 @@ await octokit.request('GET /api/yystopf/csfjkkj/tags.json') ``` -## 仓库分支列表 -仓库分支列表 +## 仓库所有分支列表 +仓库所有分支列表 > 示例: ```shell -curl -X GET http://localhost:3000/api/yystopf/csfjkkj/branches.json +curl -X GET http://localhost:3000/api/v1/yystopf/csfjkkj/branches/all.json ``` ```javascript -await octokit.request('GET /api/yystopf/csfjkkj/branches.json') +await octokit.request('GET /api/v1/yystopf/csfjkkj/branches/all.json') ``` ### HTTP 请求 -`GET /api/:owner/:repo/branches.json` +`GET /api/v1/:owner/:repo/branches/all.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 @@ -466,6 +466,95 @@ await octokit.request('GET /api/yystopf/csfjkkj/branches.json') ] ``` +## 仓库创建分支 +为仓库创建一个新的分支 + +> 示例: + +```shell +curl -X POST http://localhost:3000/api/v1/yystopf/csfjkkj/branches.json +``` + +```javascript +await octokit.request('POST /api/v1/yystopf/csfjkkj/branches.json') +``` + +### HTTP 请求 +`POST /api/v1/:owner/:repo/branches.json` + +### 请求参数: +参数 | 必选 | 默认 | 类型 | 字段说明 +--------- | ------- | ------- | -------- | ---------- +|owner |是| |string |用户登录名 | +|repo |是| |string |项目标识identifier | +|new_branch_name|是||string| 新分支名称| +|old_branch_name|否||string| 来源分支名称| + +### 返回字段说明: +参数 | 类型 | 字段说明 +--------- | ----------- | ----------- +|name |string|分支名称| +|commit.id |string|提交ID| +|commit.message |string|提交信息| +|commit.author.id |string|提交作者ID| +|commit.author.login |string|提交作者标识| +|commit.author.name |string|提交作者名称| +|commit.author.type |string|提交作者类型| +|commit.committer.id |string|提交者ID| +|commit.committer.login |string|提交者标识| +|commit.committer.name |string|提交者名称| +|commit.committer.type |string|提交者类型| +|commit.committer.image_url|string|提交者头像| +|commit.time_ago |string|分支最新提交时间距现在时间差| +|commit.timestamp |string|分支最新提交时间| +|protected |bool |是否为保护分支| +|user_can_push |bool |当前用户是否能提交| +|user_can_merge |bool |当前用户是否能合并| +|commit_id |string|提交ID| +|commit_time_from_now |string|分支最新提交时间距现在时间差| +|commit_time |string|分支最新提交时间| +|http_url |string|分支http地址| +|zip_url |string|分支zip包下载地址| +|tar_url |string|分支tar包下载地址| + +> 返回的JSON示例: + +```json +{ + "name": "new_branch_8", + "commit": { + "id": "80dd40214a58622312393b2ae693756a4781fab2", + "message": "x拟增\n\nSigned-off-by: yystopf ", + "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" + }, + "time_ago": "1天前", + "timestamp": "2022-07-13T09:54:15Z" + }, + "protected": false, + "user_can_push": true, + "user_can_merge": true, + "commit_id": "80dd40214a58622312393b2ae693756a4781fab2", + "commit_time_from_now": "1天前", + "commit_time": "2022-07-13T09:54:15Z", + "default_branch": "master", + "http_url": "http://127.0.0.1:10081/yystopf/ceshi_hook.git", + "zip_url": "http://localhost:3000/api/yystopf/ceshi_hook/archive/new_branch_8.zip", + "tar_url": "http://localhost:3000/api/yystopf/ceshi_hook/archive/new_branch_8.tar.gz" +} +``` + ## 仓库贡献者列表 仓库贡献者列表 diff --git a/app/services/api/v1/projects/branches/all_list_service.rb b/app/services/api/v1/projects/branches/all_list_service.rb index fd942288f..9e97b6dd2 100644 --- a/app/services/api/v1/projects/branches/all_list_service.rb +++ b/app/services/api/v1/projects/branches/all_list_service.rb @@ -16,12 +16,11 @@ class Api::V1::Projects::Branches::AllListService < ApplicationService $gitea_client.token = nil unless token.blank? gitea_data - rescue - raise Error, "服务器错误,请联系系统管理员!" end private def load_gitea_data @gitea_data = $gitea_client.get_repos_branch_name_set_by_owner_repo(owner, repo) + raise Error, '获取所有分支失败!' unless @gitea_data.is_a?(Hash) end end \ No newline at end of file diff --git a/app/views/api/v1/projects/branches/_simple_gitea_detail.json.jbuilder b/app/views/api/v1/projects/branches/_simple_gitea_detail.json.jbuilder index 9fee552d4..70fac8238 100644 --- a/app/views/api/v1/projects/branches/_simple_gitea_detail.json.jbuilder +++ b/app/views/api/v1/projects/branches/_simple_gitea_detail.json.jbuilder @@ -18,6 +18,9 @@ json.protected branch['protected'] json.user_can_push branch['user_can_push'] json.user_can_merge branch['user_can_merge'] json.commit_id branch['commit_id'] -json.commit_time_from_now branch['commit_time'] +json.commit_time_from_now time_from_now(branch['commit_time'].to_time) json.commit_time branch['commit_time'] -json.default_branch branch['default_branch'] \ No newline at end of file +json.default_branch branch['default_branch'] +json.http_url render_http_url(@project) +json.zip_url render_zip_url(@owner, @project.repository, branch['name']) +json.tar_url render_tar_url(@owner, @project.repository, branch['name']) \ No newline at end of file diff --git a/public/docs/api.html b/public/docs/api.html index 21b6d7f41..74430a6f4 100644 --- a/public/docs/api.html +++ b/public/docs/api.html @@ -503,7 +503,10 @@ 仓库标签列表
  • - 仓库分支列表 + 仓库所有分支列表 +
  • +
  • + 仓库创建分支
  • 仓库贡献者列表 @@ -7818,16 +7821,16 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat } } ] -

    仓库分支列表

    -

    仓库分支列表

    +

    仓库所有分支列表

    +

    仓库所有分支列表

    示例:

    -
    curl -X GET http://localhost:3000/api/yystopf/csfjkkj/branches.json
    -
    await octokit.request('GET /api/yystopf/csfjkkj/branches.json')
    +
    curl -X GET http://localhost:3000/api/v1/yystopf/csfjkkj/branches/all.json
    +
    await octokit.request('GET /api/v1/yystopf/csfjkkj/branches/all.json')
     

    HTTP 请求

    -

    GET /api/:owner/:repo/branches.json

    +

    GET /api/v1/:owner/:repo/branches/all.json

    请求参数:

    @@ -7906,16 +7909,16 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat "tar_url": "http://localhost:3000/api/yystopf/hahahah/archive/touch-100.tar.gz" } ] -

    仓库贡献者列表

    -

    仓库贡献者列表

    +

    仓库创建分支

    +

    为仓库创建一个新的分支

    示例:

    -
    curl -X GET http://localhost:3000/api/yystopf/csfjkkj/contributors.json
    -
    await octokit.request('GET /api/yystopf/csfjkkj/contributors.json')
    +
    curl -X POST http://localhost:3000/api/v1/yystopf/csfjkkj/branches.json
    +
    await octokit.request('POST /api/v1/yystopf/csfjkkj/branches.json')
     

    HTTP 请求

    -

    GET /api/:owner/:repo/contributors.json

    +

    POST /api/v1/:owner/:repo/branches.json

    请求参数:

    @@ -7940,6 +7943,20 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat + + + + + + + + + + + + + +
    string 项目标识identifier
    new_branch_name是||string新分支名称
    old_branch_name否|string来源分支名称

    返回字段说明:

    @@ -7950,6 +7967,202 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    namestring分支名称
    commit.idstring提交ID
    commit.messagestring提交信息
    commit.author.idstring提交作者ID
    commit.author.loginstring提交作者标识
    commit.author.namestring提交作者名称
    commit.author.typestring提交作者类型
    commit.committer.idstring提交者ID
    commit.committer.loginstring提交者标识
    commit.committer.namestring提交者名称
    commit.committer.typestring提交者类型
    commit.committer.image_urlstring提交者头像
    commit.time_agostring分支最新提交时间距现在时间差
    commit.timestampstring分支最新提交时间
    protectedbool是否为保护分支
    user_can_pushbool当前用户是否能提交
    user_can_mergebool当前用户是否能合并
    commit_idstring提交ID
    commit_time_from_nowstring分支最新提交时间距现在时间差
    commit_timestring分支最新提交时间
    http_urlstring分支http地址
    zip_urlstring分支zip包下载地址
    tar_urlstring分支tar包下载地址
    + +
    +

    返回的JSON示例:

    +
    +
    {
    +    "name": "new_branch_8",
    +    "commit": {
    +        "id": "80dd40214a58622312393b2ae693756a4781fab2",
    +        "message": "x拟增\n\nSigned-off-by: yystopf <yystopf@163.com>",
    +        "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"
    +        },
    +        "time_ago": "1天前",
    +        "timestamp": "2022-07-13T09:54:15Z"
    +    },
    +    "protected": false,
    +    "user_can_push": true,
    +    "user_can_merge": true,
    +    "commit_id": "80dd40214a58622312393b2ae693756a4781fab2",
    +    "commit_time_from_now": "1天前",
    +    "commit_time": "2022-07-13T09:54:15Z",
    +    "default_branch": "master",
    +    "http_url": "http://127.0.0.1:10081/yystopf/ceshi_hook.git",
    +    "zip_url": "http://localhost:3000/api/yystopf/ceshi_hook/archive/new_branch_8.zip",
    +    "tar_url": "http://localhost:3000/api/yystopf/ceshi_hook/archive/new_branch_8.tar.gz"
    +}
    +

    仓库贡献者列表

    +

    仓库贡献者列表

    + +
    +

    示例:

    +
    +
    curl -X GET http://localhost:3000/api/yystopf/csfjkkj/contributors.json
    +
    await octokit.request('GET /api/yystopf/csfjkkj/contributors.json')
    +

    HTTP 请求

    +

    GET /api/:owner/:repo/contributors.json

    +

    请求参数:

    + + + + + + + + + + + + + + + + + + + + + + + +
    参数必选默认类型字段说明
    ownerstring用户登录名
    repostring项目标识identifier
    +

    返回字段说明:

    + + + + + + + + @@ -8006,9 +8219,9 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat
    curl -X GET http://localhost:3000/api/yystopf/csfjkkj/languages.json
     
    await octokit.request('GET /api/yystopf/csfjkkj/languages.json')
    -

    HTTP 请求

    +

    HTTP 请求

    GET /api/:owner/:repo/languages.json

    -

    请求参数:

    +

    请求参数:

    参数类型字段说明
    list.contributions int 贡献者commit数量
    @@ -8033,7 +8246,7 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat
    参数项目标识identifier
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -8070,9 +8283,9 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat
    curl -X GET http://localhost:3000/api/jasder/jasder_test/edit.json
     
    await octokit.request('GET /api/jasder/jasder_test/edit.json')
    -

    HTTP 请求

    +

    HTTP 请求

    GET /api/:owner/:repo/edit.json

    -

    请求参数:

    +

    请求参数:

    参数
    @@ -8097,7 +8310,7 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat
    参数项目标识identifier
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -8174,9 +8387,9 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat -d"private=true"\ http://localhost:3000/api/jasder/jasder_test.json
    await octokit.request('PATCH /api/jasder/jasder_test.json')
    -

    HTTP 请求

    +

    HTTP 请求

    PATCH /api/:owner/:repo

    -

    请求参数:

    +

    请求参数:

    参数
    @@ -8236,7 +8449,7 @@ http://localhost:3000/api/jasder/jasder_test.json
    参数项目是否私有, true:为私有,false: 公开,默认为公开
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -8301,9 +8514,9 @@ http://localhost:3000/api/jasder/jasder_test.json
    curl -X DELETE http://localhost:3000/api/jasder/jasder_test.json
     
    await octokit.request('DELETE /api/jasder/jasder_test.json')
    -

    HTTP 请求

    +

    HTTP 请求

    PATCH /api/:owner/:repo

    -

    请求参数:

    +

    请求参数:

    参数
    @@ -8328,7 +8541,7 @@ http://localhost:3000/api/jasder/jasder_test.json
    参数项目标识identifier
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -8369,83 +8582,8 @@ http://localhost:3000/api/jasder/jasder_test.json -d"user_id=12"\ http://localhost:3000/api/jasder/jasder_test/collaborators.json
    await octokit.request('POST /api/jasder/jasder_test/collaborators.json')
    -

    HTTP 请求

    -

    POST /api/:owner/:repo/collaborators.json

    -

    请求参数:

    -
    参数
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    参数必选默认类型字段说明
    ownerstring用户登录名
    repostring项目标识identifier
    user_idint用户id
    -

    返回字段说明:

    - - - - - - - - - - - - - - - - - -
    参数类型字段说明
    statusint返回状态, 0: 表示操作成功
    messagestring返回信息说明
    - -
    -

    返回的JSON示例:

    -
    -
    {
    -  "status": 0,
    -  "message": "success"
    -}
    -
    - -

    删除仓库成员

    -

    仓库中删除成员操作

    - -
    -

    示例:

    -
    -
    curl -X DELETE \
    --d "user_id=12" \
    -http://localhost:3000/api/jasder/jasder_test/collaborators.json
    -
    await octokit.request('DELETE /api/jasder/jasder_test/collaborators.json')
     

    HTTP 请求

    -

    DELETE /api/:owner/:repo/collaborators.json

    +

    POST /api/:owner/:repo/collaborators.json

    请求参数:

    @@ -8498,6 +8636,81 @@ http://localhost:3000/api/jasder/jasder_test/collaborators.json
    +
    +

    返回的JSON示例:

    +
    +
    {
    +  "status": 0,
    +  "message": "success"
    +}
    +
    + +

    删除仓库成员

    +

    仓库中删除成员操作

    + +
    +

    示例:

    +
    +
    curl -X DELETE \
    +-d "user_id=12" \
    +http://localhost:3000/api/jasder/jasder_test/collaborators.json
    +
    await octokit.request('DELETE /api/jasder/jasder_test/collaborators.json')
    +

    HTTP 请求

    +

    DELETE /api/:owner/:repo/collaborators.json

    +

    请求参数:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数必选默认类型字段说明
    ownerstring用户登录名
    repostring项目标识identifier
    user_idint用户id
    +

    返回字段说明:

    + + + + + + + + + + + + + + + + + +
    参数类型字段说明
    statusint返回状态, 0: 表示操作成功
    messagestring返回信息说明
    +

    返回的JSON示例:

    @@ -8520,9 +8733,9 @@ http://localhost:3000/api/jasder/jasder_test/collaborators.json -d "role=Developer" \ http://localhost:3000/api/jasder/jasder_test/change_role.json
    await octokit.request('PUT /api/jasder/jasder_test/change_role.json')
    -

    HTTP 请求

    +

    HTTP 请求

    PUT /api/:owner/:repo/change_role.json

    -

    请求参数:

    +

    请求参数:

    @@ -8561,7 +8774,7 @@ http://localhost:3000/api/jasder/jasder_test/change_role.json
    参数取值范围:"Manager", "Developer", "Reporter";分别为项目管理人员(拥有所有操作权限)、项目开发人员(只拥有读写权限)、项目报告人员(只拥有读权限)
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -8603,9 +8816,9 @@ http://localhost:3000/api/jasder/jasder_test/change_role.json -d"limit=5"\ http://localhost:3000/api/jasder/jasder_test/collaborators.json
    await octokit.request('GET /api/jasder/jasder_test/collaborators.json')
    -

    HTTP 请求

    +

    HTTP 请求

    GET /api/:owner/:repo/collaborators.json

    -

    请求参数:

    +

    请求参数:

    参数
    @@ -8644,7 +8857,7 @@ http://localhost:3000/api/jasder/jasder_test/collaborators.json
    参数每页多少条数据,默认15条
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -8732,9 +8945,9 @@ http://localhost:3000/api/jasder/jasder_test/collaborators.json -d"ref=develop"\ http://localhost:3000/api/yystopf/ceshi/files.json
    await octokit.request('GET /api/yystopf/ceshi/files.json')
    -

    HTTP 请求

    +

    HTTP 请求

    GET /api/:owner/:repo/files

    -

    请求参数:

    +

    请求参数:

    参数
    @@ -8773,7 +8986,7 @@ http://localhost:3000/api/yystopf/ceshi/files.json
    参数分支名,默认为仓库默认分支
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -8855,9 +9068,9 @@ http://localhost:3000/api/yystopf/ceshi/files.json -d"ref=develop"\ http://localhost:3000//api/jasder/jasder_test/entries.json
    await octokit.request('GET /api/jasder/jasder_test/entries.json')
    -

    HTTP 请求

    +

    HTTP 请求

    GET /api/:owner/:repo/entries.json

    -

    请求参数:

    +

    请求参数:

    参数
    @@ -8889,7 +9102,7 @@ http://localhost:3000//api/jasder/jasder_test/entries.json
    参数分支名称、tag名称或是提交记录id,默认为master分支
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -9003,9 +9216,9 @@ http://localhost:3000//api/jasder/jasder_test/entries.json -d"filepath=file"\ http://localhost:3000//api/jasder/jasder_test/sub_entries.json
    await octokit.request('GET /api/jasder/jasder_test/sub_entries.json')
    -

    HTTP 请求

    +

    HTTP 请求

    GET /api/:owner/:repo/sub_entries.json

    -

    请求参数:

    +

    请求参数:

    参数
    @@ -9044,7 +9257,7 @@ http://localhost:3000//api/jasder/jasder_test/sub_entries.json
    参数分支名称、tag名称或是提交记录id,默认为master分支
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -9141,9 +9354,9 @@ http://localhost:3000//api/jasder/jasder_test/sub_entries.json -d"filepath=lib"\ http://localhost:3000/api/yystopf/csfjkkj/readme.json
    await octokit.request('GET /api/yystopf/csfjkkj/readme.json')
    -

    HTTP 请求

    +

    HTTP 请求

    GET /api/:owner/:repo/readme.json

    -

    请求参数:

    +

    请求参数:

    参数
    @@ -9182,7 +9395,7 @@ http://localhost:3000/api/yystopf/csfjkkj/readme.json
    参数子目录名称,默认为空
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -9254,9 +9467,9 @@ http://localhost:3000/api/yystopf/csfjkkj/readme.json -d"filepath=lib"\ http://localhost:3000/api/yystopf/csfjkkj/contributors.json
    await octokit.request('GET /api/yystopf/csfjkkj/contributors.json')
    -

    HTTP 请求

    +

    HTTP 请求

    GET /api/:owner/:repo/contributors.json

    -

    请求参数:

    +

    请求参数:

    参数
    @@ -9295,7 +9508,7 @@ http://localhost:3000/api/yystopf/csfjkkj/contributors.json
    参数子目录名称,默认为空
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -9370,9 +9583,9 @@ http://localhost:3000/api/yystopf/csfjkkj/contributors.json
    curl -X GET \
     http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
     
    await octokit.request('GET /api/v1/yystopf/ceshi/webhooks.json')
    -

    HTTP 请求

    +

    HTTP 请求

    GET /api/v1/:owner/:repo/webhooks.json

    -

    请求参数:

    +

    请求参数:

    参数
    @@ -9397,7 +9610,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
    参数项目标识identifier
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -9490,9 +9703,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
    curl -X GET \
     http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3.json
     
    await octokit.request('GET /api/v1/yystopf/ceshi/webhooks/3.json')
    -

    HTTP 请求

    +

    HTTP 请求

    GET /api/v1/:owner/:repo/webhooks/:id.json

    -

    请求参数:

    +

    请求参数:

    参数
    @@ -9524,7 +9737,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3.json
    参数webhook ID
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -9647,214 +9860,8 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3.json
    curl -X POST \
     http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
     
    await octokit.request('POST /api/v1/yystopf/ceshi/webhooks.json')
    -

    HTTP 请求

    -

    POST /api/v1/:owner/:repo/webhooks.json

    -

    请求参数:

    -
    参数
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    参数必选默认类型字段说明
    ownerstring用户登录名
    repostring项目标识identifier
    webhook.urlstring目标url
    webhook.http_methodstringhttp方法, POST和GET
    webhook.content_typestringPOST Content Type
    webhook.secretstring密钥文本
    webhook.activebool是否激活
    webhook.branch_filterstring分支过滤
    webhook.eventsarray触发事件
    - -

    触发事件字段说明

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    参数含义
    create创建分支或标签
    delete分支或标签删除
    pushgit仓库推送
    pull_request合并请求
    pull_request_assign合并请求被指派
    pull_request_review_approved合并请求被批准
    pull_request_review_rejected合并请求被拒绝
    - -
    -

    请求的JSON示例:

    -
    -
    {
    -    "active": true, 
    -    "content_type": "json",
    -    "http_method": "GET",
    -    "secret": "123456",
    -    "url": "http://localhost:10000",
    -    "branch_filter": "*",
    -    "events": ["push"]
    -}
    -

    返回字段说明:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    参数类型字段说明
    idintid
    urlstring地址
    content_typestringPOST Content Type
    is_activebool是否激活
    typestring类型
    eventsarray触发事件
    create_timestring创建时间
    - -
    -

    返回的JSON示例:

    -
    -
    {
    -    "id": 68,
    -    "content_type": "json",
    -    "http_method": "GET",
    -    "url": "http://127.0.0.1:3000",
    -    "events": [
    -        "create",
    -        "delete",
    -        "push",
    -        "pull_request",
    -        "pull_request_assign",
    -        "pull_request_review_approved",
    -        "pull_request_review_rejected"
    -    ],
    -    "active": true,
    -    "branch_filter": "*",
    -    "created_at": "2022-06-23 15:52"
    -}
    -
    - -

    更新仓库webhook

    -

    更新仓库webhook

    - -
    -

    示例:

    -
    -
    curl -X PATCH \
    -http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
    -
    await octokit.request('PATCH /api/v1/yystopf/ceshi/webhooks/7.json')
     

    HTTP 请求

    -

    PATCH /api/v1/:owner/:repo/webhooks/68.json

    +

    POST /api/v1/:owner/:repo/webhooks.json

    请求参数:

    @@ -9880,13 +9887,6 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json - - - - - - - @@ -9988,6 +9988,219 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json "events": ["push"] }

    返回字段说明:

    +
    项目标识identifier
    idstringwebhook id
    webhook.url
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数类型字段说明
    idintid
    urlstring地址
    content_typestringPOST Content Type
    is_activebool是否激活
    typestring类型
    eventsarray触发事件
    create_timestring创建时间
    + +
    +

    返回的JSON示例:

    +
    +
    {
    +    "id": 68,
    +    "content_type": "json",
    +    "http_method": "GET",
    +    "url": "http://127.0.0.1:3000",
    +    "events": [
    +        "create",
    +        "delete",
    +        "push",
    +        "pull_request",
    +        "pull_request_assign",
    +        "pull_request_review_approved",
    +        "pull_request_review_rejected"
    +    ],
    +    "active": true,
    +    "branch_filter": "*",
    +    "created_at": "2022-06-23 15:52"
    +}
    +
    + +

    更新仓库webhook

    +

    更新仓库webhook

    + +
    +

    示例:

    +
    +
    curl -X PATCH \
    +http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
    +
    await octokit.request('PATCH /api/v1/yystopf/ceshi/webhooks/7.json')
    +

    HTTP 请求

    +

    PATCH /api/v1/:owner/:repo/webhooks/68.json

    +

    请求参数:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数必选默认类型字段说明
    ownerstring用户登录名
    repostring项目标识identifier
    idstringwebhook id
    webhook.urlstring目标url
    webhook.http_methodstringhttp方法, POST和GET
    webhook.content_typestringPOST Content Type
    webhook.secretstring密钥文本
    webhook.activebool是否激活
    webhook.branch_filterstring分支过滤
    webhook.eventsarray触发事件
    + +

    触发事件字段说明

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数含义
    create创建分支或标签
    delete分支或标签删除
    pushgit仓库推送
    pull_request合并请求
    pull_request_assign合并请求被指派
    pull_request_review_approved合并请求被批准
    pull_request_review_rejected合并请求被拒绝
    + +
    +

    请求的JSON示例:

    +
    +
    {
    +    "active": true, 
    +    "content_type": "json",
    +    "http_method": "GET",
    +    "secret": "123456",
    +    "url": "http://localhost:10000",
    +    "branch_filter": "*",
    +    "events": ["push"]
    +}
    +

    返回字段说明:

    返回的JSON示例:

    @@ -10022,9 +10235,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
    curl -X DELETE \
     http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
     
    await octokit.request('DELETE /api/v1/yystopf/ceshi/webhooks/7.json')
    -

    HTTP 请求

    +

    HTTP 请求

    DELETE /api/v1/:owner/:repo/webhooks/:id.json

    -

    请求参数:

    +

    请求参数:

    @@ -10056,7 +10269,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
    参数webhook id
    -

    返回字段说明:

    +

    返回字段说明:

    返回的JSON示例:

    @@ -10077,9 +10290,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
    curl -X GET \
     http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/hooktasks.json
     
    await octokit.request('GET /api/v1/yystopf/ceshi/webhooks/3/hooktasks.json')
    -

    HTTP 请求

    +

    HTTP 请求

    GET /api/v1/:owner/:repo/webhooks/:id/hooktasks.json

    -

    请求参数:

    +

    请求参数:

    @@ -10111,7 +10324,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/hooktasks.json
    参数webhook ID
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -10348,9 +10561,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/hooktasks.json
    curl -X POST \
     http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/tests.json
     
    await octokit.request('POST /api/v1/yystopf/ceshi/webhooks/3/tests.json')
    -

    HTTP 请求

    +

    HTTP 请求

    POST /api/v1/:owner/:repo/webhooks/:id/tests.json

    -

    请求参数:

    +

    请求参数:

    参数
    @@ -10382,7 +10595,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/tests.json
    参数webhook ID
    -

    返回字段说明:

    +

    返回字段说明:

    返回的JSON示例: