# Repositories ## 仓库详情 仓库详情 > 示例: ```shell curl -X GET http://localhost:3000/api/jasder/jasder_test.json ``` ```javascript await octokit.request('GET /api/jasder/jasder_test.json') ``` ### HTTP 请求 `GET /api/:owner/:repo` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |identifier |string|项目标识| |name |string|项目名称| |project_id |int |项目ID | |repo_id |int |仓库ID| |issues_count |int |疑修数量| |pull_requests_count |int |合并请求数量| |project_identifier |string|项目标识| |praises_count |int |项目点赞数| |forked_count |int |项目复刻数| |watchers_count |int |项目关注数| |versions_count |int |项目里程碑数量| |version_releases_count |int |项目版本数| |version_releasesed_count |int |项目已发行项目版本数| |contributor_users_count |int |项目贡献者数| |permission |string|用户权限 Admin: 平台管理员, Manager: 项目管理员, Developer: 项目开发者, Reporter: 项目报告者| |mirror_url |string|项目镜像地址| |mirror |bool |是否为镜像项目| |type |int |项目类型 0: 托管项目,1: 镜像项目,2: 同步镜像项目| |forked_from_project_id |int |项目复刻来源项目ID| |fork_info.fork_form_name |string|项目复刻来源项目的名称| |fork_info.fork_project_user_login|string|项目复刻来源项目拥有者标识| |fork_info.fork_project_identifier|string|项目复刻来源项目标识| |fork_info.fork_project_user_name |string|项目复刻来源项目拥有者名称| |size |string|项目大小| |ssh_url |string|项目ssh clone地址| |clone_url |string|项目http clone地址| |default_branch |string|项目默认分支| |empty |bool |项目是否为空| |full_name |string|项目路径| |private |bool |项目是否为私有项目| |author.id |int |项目拥有者ID| |author.login |string|项目拥有者标识| |author.type |string|项目拥有者类型| |author.name |string|项目拥有者名称| |author.image_url |string|项目拥有者头像地址| > 返回的JSON示例: ```json { "identifier": "hahahah", "name": "hahahah", "project_id": 469, "repo_id": 469, "issues_count": 2, "pull_requests_count": 3, "project_identifier": "hahahah", "praises_count": 0, "forked_count": 1, "watchers_count": 0, "versions_count": 0, "version_releases_count": 0, "version_releasesed_count": 0, "contributor_users_count": 1, "permission": "Admin", "mirror_url": null, "mirror": false, "type": 0, "open_devops": false, "watched": false, "praised": false, "status": 1, "forked_from_project_id": null, "size": "2.1 MB", "ssh_url": "virus@127.0.0.1:10081:yystopf/hahahah.git", "clone_url": "http://127.0.0.1:10081/yystopf/hahahah.git", "default_branch": "master", "empty": false, "full_name": "yystopf/hahahah", "private": false, "author": { "id": 2, "login": "yystopf", "type": "User", "name": "heh", "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png" } } ``` ## 仓库详情(简版) 仓库详情 > 示例: ```shell curl -X GET http://localhost:3000/api/jasder/jasder_test/simple.json ``` ```javascript await octokit.request('GET /api/jasder/jasder_test/simple.json') ``` ### HTTP 请求 `GET /api/:owner/:repo/simple` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |id |int |id | |name |string|项目名称| |platform |string|项目平台| |identifier |string|项目标识| |repo_id |int |仓库id| |open_devops |bool |是否开启工作流| |type |int |项目类型 0: 托管项目,1: 镜像项目,2: 同步镜像项目| |author.login |string|项目拥有者标识| |author.type |string|项目拥有者类型| |author.name |string|项目拥有者名称| |author.image_url|string|项目拥有者头像地址| > 返回的JSON示例: ```json { "identifier": "hahahah", "name": "hahahah", "platform": "forge", "id": 469, "repo_id": 469, "open_devops": false, "type": 0, "author": { "login": "yystopf", "name": "heh", "type": "User", "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png" } } ``` ## 仓库详情(新版) 仓库详情 > 示例: ```shell curl -X GET http://localhost:3000/api/yystopf/ceshi/detail.json ``` ```javascript await octokit.request('GET /api/yystopf/ceshi/detail.json') ``` ### HTTP 请求 `GET /api/:owner/:repo/detail` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |content |string |仓库简介 | |website |string |仓库网址 | |lesson_url |string |课程地址 | |identifier |string |项目标识 | |invite_code |string |项目邀请码 | |name |string |项目名称 | |description |string |项目描述 | |project_id |int |项目ID | |repo_id |int |仓库ID| |issues_count |int |项目issue数量| |pull_requests_count |int |项目合并请求数量| |project_identifier |int |项目标识| |praises_count |int |项目点赞数量| |forked_count |int |项目复刻数量| |watchers_count |int |项目关注数量| |versions_count |int |项目里程碑数量| |version_releases_count |int |项目发行版数量| |version_releasesed_count |int |项目发行版已发行数量| |permission |string |项目权限, Admin: 平台管理员,Manager: 项目管理员, Developer: 项目开发者, Reporter: 项目报告者| |mirror_url |string |镜像地址| |mirror |bool |是否为镜像项目| |type |int |项目类型 0 普通项目 1 普通镜像项目 2 同步镜像项目| |open_devops |int |是否开启devops| |watched |bool |是否关注| |praised |bool |是否点赞| |status |int |项目状态| |forked_from_project_id |int |项目复刻来源项目id| |fork_info.fork_form_name |string |项目复刻来源项目的名称| |fork_info.fork_project_user_login|string |项目复刻来源项目拥有者标识| |fork_info.fork_project_identifier|string |项目复刻来源项目标识| |fork_info.fork_project_user_name |string |项目复刻来源项目拥有者名称| |size |string |仓库大小| |ssh_url |string |项目ssh克隆地址| |clone_url |string |项目http克隆地址| |default_branch |string |仓库默认分支| |empty |bool |仓库是否为空| |full_name |string |仓库全称| |private |bool |仓库是否为私有项目| |license_name |string |许可证名称| |author.id |int |项目拥有者ID| |author.login |string |项目拥有者标识| |author.type |string |项目拥有者类型| |author.name |string |项目拥有者名称| |author.image_url |string |项目拥有者头像地址| > 返回的JSON示例: ```json { "content": null, "website": null, "lesson_url": null, "identifier": "hahahah", "invite_code": "8zfKtM", "name": "hahahah", "description": null, "project_id": 469, "repo_id": 469, "issues_count": 2, "pull_requests_count": 2, "project_identifier": "hahahah", "praises_count": 0, "forked_count": 1, "watchers_count": 0, "versions_count": 0, "version_releases_count": 0, "version_releasesed_count": 0, "permission": "Admin", "mirror_url": null, "mirror": false, "type": 0, "open_devops": false, "watched": false, "praised": false, "status": 1, "forked_from_project_id": null, "size": "2.1 MB", "ssh_url": "virus@127.0.0.1:10081:yystopf/hahahah.git", "clone_url": "http://127.0.0.1:10081/yystopf/hahahah.git", "default_branch": "master", "empty": false, "full_name": "yystopf/hahahah", "private": false, "license_name": null, "branches_count": 1201, "tags_count": 0, "author": { "id": 2, "login": "yystopf", "type": "User", "name": "heh", "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png" } } ``` ## 仓库标签列表 仓库标签列表 > 示例: ```shell curl -X GET http://localhost:3000/api/yystopf/csfjkkj/tags.json ``` ```javascript await octokit.request('GET /api/yystopf/csfjkkj/tags.json') ``` ### HTTP 请求 `GET /api/:owner/:repo/tags.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | |page |否| 1 | integer | 页码 | |limit |否| 20| integer | 每页个数 | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |id |int |标签id | |name |string|标签名称| |zipball_url |string|标签zip包下载地址| |tarball_url |string|标签tar包下载地址| |tagger |object|打标签的人| |time_ago |string|打标签的时间| |created_at_unix|string|打标签的时间戳| |message |string|标签信息| |commit |object|标签最后一个commit| |commit.sha |string|commit的id| |commit.message |string|commit的提交信息| |commit.time_ago|string|commit的提交时间| |commit.created_at_unix|string|commit的提交时间戳| |commit.committer|object|commit的提交者| |commit.author|object|commit的作者| > 返回的JSON示例: ```json [ { "name": "v2.0.0", "id": "c7d0873ee41796d1a0e193063095ccf539a9bf31", "zipball_url": "http://localhost:3000/api/yystopf/csfjkkj/archive/v2.0.0.zip", "tarball_url": "http://localhost:3000/api/yystopf/csfjkkj/archive/v2.0.0.tar.gz", "tagger": { "id": 4, "login": "testforge1", "name": "testforge1", "image_url": "system/lets/letter_avatars/2/T/19_237_174/120.png" }, "time_ago": "1天前", "created_at_unix": 1632376903, "message": "jdfkls", "commit": { "sha": "08fe383f1e5ebe2e2a384a8ea3ee890a758c7cd7", "message": "add\n", "time_ago": "1天前", "created_at_unix": 1632376186, "committer": { "id": 4, "login": "testforge1", "name": "testforge1", "image_url": "system/lets/letter_avatars/2/T/19_237_174/120.png" }, "author": { "id": 4, "login": "testforge1", "name": "testforge1", "image_url": "system/lets/letter_avatars/2/T/19_237_174/120.png" } } }, { "name": "v1.0.0", "id": "12168ad39c3ef201a445a2db181a3e43d50e40dd", "zipball_url": "http://localhost:3000/api/yystopf/csfjkkj/archive/v1.0.0.zip", "tarball_url": "http://localhost:3000/api/yystopf/csfjkkj/archive/v1.0.0.tar.gz", "tagger": { "id": null, "login": "viletyy", "name": "viletyy", "image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png" }, "time_ago": "10天前", "created_at_unix": 1631588042, "message": "dfks", "commit": { "sha": "5291b5e45a377c1f7710cc6647259887ed7aaccf", "message": "ADD file via upload\n", "time_ago": "21天前", "created_at_unix": 1630648417, "committer": { "id": null, "login": "yystopf", "name": "yystopf", "image_url": "system/lets/letter_avatars/2/Y/241_125_89/120.png" }, "author": { "id": null, "login": "yystopf", "name": "yystopf", "image_url": "system/lets/letter_avatars/2/Y/241_125_89/120.png" } } } ] ``` ## 仓库所有分支列表 仓库所有分支列表 > 示例: ```shell curl -X GET http://localhost:3000/api/v1/yystopf/csfjkkj/branches/all.json ``` ```javascript await octokit.request('GET /api/v1/yystopf/csfjkkj/branches/all.json') ``` ### HTTP 请求 `GET /api/v1/:owner/:repo/branches/all.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |name |string|分支名称| |http_url |string|分支http地址| |zip_url |string|分支zip包下载地址| |tar_url |string|分支tar包下载地址| > 返回的JSON示例: ```json [ { "name": "master", "http_url": "http://127.0.0.1:10081/yystopf/hahahah.git", "zip_url": "http://localhost:3000/api/yystopf/hahahah/archive/master.zip", "tar_url": "http://localhost:3000/api/yystopf/hahahah/archive/master.tar.gz" }, { "name": "touch-10", "http_url": "http://127.0.0.1:10081/yystopf/hahahah.git", "zip_url": "http://localhost:3000/api/yystopf/hahahah/archive/touch-10.zip", "tar_url": "http://localhost:3000/api/yystopf/hahahah/archive/touch-10.tar.gz" }, { "name": "touch-100", "http_url": "http://127.0.0.1:10081/yystopf/hahahah.git", "zip_url": "http://localhost:3000/api/yystopf/hahahah/archive/touch-100.zip", "tar_url": "http://localhost:3000/api/yystopf/hahahah/archive/touch-100.tar.gz" } ] ``` ## 仓库创建分支 为仓库创建一个新的分支 > 示例: ```shell curl -X POST \ -d "new_branch_name=ceshi_branch_1" \ -d "old_branch_name=master" \ 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" } ``` ## 仓库贡献者列表 仓库贡献者列表 > 示例: ```shell curl -X GET http://localhost:3000/api/yystopf/csfjkkj/contributors.json ``` ```javascript await octokit.request('GET /api/yystopf/csfjkkj/contributors.json') ``` ### HTTP 请求 `GET /api/:owner/:repo/contributors.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |list.contributions |int |贡献者commit数量| |list.login |string|贡献者标识| |list.type |string|贡献者类型| |list.name |string|贡献者昵称| |list.image_url |string|贡献者头像地址| > 返回的JSON示例: ```json { "list": [ { "contributions": 2411, "login": "yystopf", "type": "User", "name": "heh", "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png" }, { "contributions": 6, "login": "testforge3", "type": null, "name": "testforge3", "image_url": "system/lets/letter_avatars/2/T/132_143_60/120.png" } ], "total_count": 2 } ``` ## 仓库开发语言 仓库开发语言组成 > 示例: ```shell curl -X GET http://localhost:3000/api/yystopf/csfjkkj/languages.json ``` ```javascript await octokit.request('GET /api/yystopf/csfjkkj/languages.json') ``` ### HTTP 请求 `GET /api/:owner/:repo/languages.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |key |string |语言类型| |value |string |语言占比| > 返回的JSON示例: ```json { "Go": "99.0%", "Shell": "0.4%", "Smarty": "0.4%", "Makefile": "0.2%" } ``` ## 编辑仓库信息 编辑仓库信息 > 示例: ```shell curl -X GET http://localhost:3000/api/jasder/jasder_test/edit.json ``` ```javascript await octokit.request('GET /api/jasder/jasder_test/edit.json') ``` ### HTTP 请求 `GET /api/:owner/:repo/edit.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |identifier |string |仓库标识 | |project_id |int|项目id| |project_name |string|项目名称| |project_identifier |string|项目标识| |project_description |string|项目简介| |project_category_id |int|项目类别id| |project_language_id |int|项目语言id| |private |boolean|项目是否私有, true:为私有,false: 公开 | > 返回的JSON示例: ```json { "identifier": "project", "project_id": 3263, "project_name": "项目", "project_identifier": "project identifier", "project_description": "project description", "project_category_id": 1, "project_language_id": 2, "private": false } ``` ## 修改仓库信息 修改仓库信息 > 示例: ```shell curl -X PATCH \ -d "name=hnfl_demo" \ -d "description=my first project" \ -d "project_category_id=1" \ -d "project_language_id=2" \ -d "private=true" \ http://localhost:3000/api/jasder/jasder_test.json ``` ```javascript await octokit.request('PATCH /api/jasder/jasder_test.json') ``` ### HTTP 请求 `PATCH /api/:owner/:repo` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |id |是 | |int |项目id | |name |否 | |string |项目名称 | |description |否 | |string |项目描述 | |project_category_id|否 | |int |项目类别id | |project_language_id|否 | |int |项目语言id | |default_branch |否 | |string |默认分支名称 | |private |否 | |boolean|项目是否私有, true:为私有,false: 公开,默认为公开 | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |id |int|id | |identifier |string|项目标识| |name |string|项目名称| |description |string|项目简介| |project_category_id|int|项目类别id| |project_language_id|int|项目语言id| |private |否|boolean|项目是否私有, true:为私有,false: 公开,默认为公开 | > 返回的JSON示例: ```json { "id": 3263, "identifier": "project identifier", "name": "project name", "description": "project description", "project_category_id": 1, "project_language_id": 2, "is_public": true } ``` ## 删除仓库 删除仓库 > 示例: ```shell curl -X DELETE http://localhost:3000/api/jasder/jasder_test.json ``` ```javascript await octokit.request('DELETE /api/jasder/jasder_test.json') ``` ### HTTP 请求 `PATCH /api/:owner/:repo` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |status |int|返回状态, 0: 表示操作成功 | |message |string|返回信息说明| > 返回的JSON示例: ```json { "status": 0, "message": "success" } ``` ## 添加仓库成员 仓库中添加成员操作 > 示例: ```shell curl -X POST \ -d "user_id=12" \ http://localhost:3000/api/jasder/jasder_test/collaborators.json ``` ```javascript await octokit.request('POST /api/jasder/jasder_test/collaborators.json') ``` ### HTTP 请求 `POST /api/:owner/:repo/collaborators.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | |user_id |是|int | |用户id | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |status |int|返回状态, 0: 表示操作成功 | |message |string|返回信息说明| > 返回的JSON示例: ```json { "status": 0, "message": "success" } ``` ## 删除仓库成员 仓库中删除成员操作 > 示例: ```shell curl -X DELETE \ -d "user_id=12" \ http://localhost:3000/api/jasder/jasder_test/collaborators.json ``` ```javascript await octokit.request('DELETE /api/jasder/jasder_test/collaborators.json') ``` ### HTTP 请求 `DELETE /api/:owner/:repo/collaborators.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | |user_id |是|int | |用户id | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |status |int|返回状态, 0: 表示操作成功 | |message |string|返回信息说明| > 返回的JSON示例: ```json { "status": 0, "message": "success" } ``` ## 更改仓库成员角色(权限) 更改仓库成员角色 > 示例: ```shell curl -X PUT \ -d "user_id=12" \ -d "role=Developer" \ http://localhost:3000/api/jasder/jasder_test/change_role.json ``` ```javascript await octokit.request('PUT /api/jasder/jasder_test/change_role.json') ``` ### HTTP 请求 `PUT /api/:owner/:repo/change_role.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | |user_id |是|int | |用户id | |role |是|string | |取值范围:"Manager", "Developer", "Reporter";分别为项目管理人员(拥有所有操作权限)、项目开发人员(只拥有读写权限)、项目报告人员(只拥有读权限) | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |status |int|返回状态, 0: 表示操作成功 | |message |string|返回信息说明| > 返回的JSON示例: ```json { "status": 0, "message": "success" } ``` ## 获取仓库成员列表 获取仓库成员列表 > 示例: ```shell curl -X GET \ -d "page=1" \ -d "limit=5" \ http://localhost:3000/api/jasder/jasder_test/collaborators.json ``` ```javascript await octokit.request('GET /api/jasder/jasder_test/collaborators.json') ``` ### HTTP 请求 `GET /api/:owner/:repo/collaborators.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | |page |否| |string |页数,第几页 | |limit |否| |string |每页多少条数据,默认15条 | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |total_count |int |返回记录总条数 | |members |array|项目成员信息| |-- id |int|用户id| |-- name |string|用户名称| |-- login |string|用户登录名/标识| |-- image_url |string|用户头像| |-- is_owner |boolean|是否是项目的拥有者,true:是, false:不是| |-- role |string|该用户在项目中的角色, Manager: 管理员(拥有操作权限); Developer:开发人员(只拥有读写权限); Reporter:报告人员(只拥有读权限)| > 返回的JSON示例: ```json { "total_count": 2, "members": [ { "id": 36401, "name": "name", "login": "login", "image_url": "avatars/User/b", "is_owner": true, "role": "Manager" }, { "id": 36399, "name": "name", "login": "login", "image_url": "avatars/User/b", "is_owner": false, "role": "Developer" } ] } ``` ## 获取仓库所有文件 获取仓库所有文件 > 示例: ```shell curl -X GET \ -d "ref=develop" \ http://localhost:3000/api/yystopf/ceshi/files.json ``` ```javascript await octokit.request('GET /api/yystopf/ceshi/files.json') ``` ### HTTP 请求 `GET /api/:owner/:repo/files` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | |search |否| |string |文件搜索关键词 | |ref |是| |string |分支名,默认为仓库默认分支 | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |name |string |文件名称| |path |string |文件路径| |sha |string |文件标识| |type |string |文件类型| |size |int |文件大小| |url |string |文件地址| > 返回的JSON示例: ```json [ { "name": ".gitignore", "path": ".gitignore", "sha": "f83922d01ae60f6e637a1a2b9f08871b4f87dfc8", "type": "file", "size": 63, "url": "http://localhost:10080/api/v1/repos/yystopf/ceshi/contents/.gitignore?ref=master", "html_url": "http://localhost:10080/yystopf/ceshi/src/branch/master/.gitignore" }, { "name": "LICENSE", "path": "LICENSE", "sha": "8f3b9ab0d08afd3a624d822e3971a2f42b3bc2b9", "type": "file", "size": 341, "url": "http://localhost:10080/api/v1/repos/yystopf/ceshi/contents/LICENSE?ref=master", "html_url": "http://localhost:10080/yystopf/ceshi/src/branch/master/LICENSE" }, { "name": "README.md", "path": "README.md", "sha": "1bc8a60ac6ddc876ebc4b60fc68991435bfad93e", "type": "file", "size": 9, "url": "http://localhost:10080/api/v1/repos/yystopf/ceshi/contents/README.md?ref=master", "html_url": "http://localhost:10080/yystopf/ceshi/src/branch/master/README.md" } ] ``` ## 提交文件到仓库 提交文件到仓库,支持批量 > 示例: ```shell curl -X POST \ -d "files[][action_type]=create" \ -d "files[][content]=jfksj" \ -d "files[][encoding]=text" \ -d "files[][file_path]=heihei8" \ -d "author_email=yystopf@163.com" \ -d "author_name=yystopf" \ -d "author_timeunix=1658214400" \ -d "committer_email=yystopf@163.com" \ -d "committer_name=yystopf" \ -d "committer_timeunix=1658214400" \ -d "branch=develop" \ -d "new_branch=develop_ceshi" \ -d "message=测试提交" \ http://localhost:3000/api/v1/yystopf/ceshi/contents/batch.json ``` ```javascript await octokit.request('POST /api/v1/yystopf/ceshi/contents/batch.json') ``` ### HTTP 请求 `POST /api/v1/:owner/:repo/contents/batch` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | |files.action_type |是| |string|操作类型 create: 创建 update: 更新 delete: 删除| |files.content |是| |string|文件内容| |files.encoding |是| |string|文件编码方式 text 文本 base64 加密| |files.file_path |是| |string|文件路径| |author_email |否| 当前用户邮箱 |string|作者邮箱,不填时需要与作者名称同时为空| |author_name |否| 当前用户标识 |string|作者名称,不填时需要与作者邮箱同时为空| |author_timeunix |否| 当前时间戳 |int|编码时间,精确到秒| |committer_email |否| 当前用户邮箱 |string|提交者邮箱,不填时需要与提交者名称同时为空| |committer_name |否| 当前用户标识 |string|提交者名称,不填时需要与提交者邮箱同时为空| |committer_timeunix|否| 当前时间戳 |int|提交时间戳,精确到秒| |branch |是| |string|提交分支| |new_branch |否| |string|如果需要创建新分支,这个需要填| |message |是| |string|提交信息| > 请求的JSON示例: ```json { "files": [ { "action_type": "create", "content": "jfksj", "encoding": "text", "file_path": "heihei7" } ], "author_email": "yystopf@163.com", "author_name": "yystopf", "author_timeunix": 1658214400, "committer_email": "yystopf@163.com", "committer_name": "yystopf", "committer_timeunix": 1658214400, "branch": "hh_ceshi", "message": "测试提交" } ``` ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |commit.sha |string |提交ID| |commit.author |object |作者| |commit.committer |object |提交者| |commit.commit_message|string |提交信息| |commit.parent_shas |array |父节点commit ID| |commit.authored_time|int |编码时间| |commit.commited_time|int |提交时间| |contents.name |string |文件名称| |contents.path |string |文件路径| |contents.sha |string |文件标识| |contents.type |string |文件类型| |contents.size |int |文件大小| |contents.url |string |文件地址| |contents.encoding |string |编码类型 text 文本 base64 加密 | |contents.content |string |文件内容| > 返回的JSON示例: ```json { "commit": { "sha": "7c1e25f9b974e4b7a3816bd7f5e49b441078e999", "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" }, "commit_message": "测试提交\n", "parent_shas": [ "9aec816d0f3600082ca77893290a14bd29d805fe" ], "authored_time": 1658214400, "commited_time": 1658214400 }, "contents": [ { "name": "heihei7", "path": "heihei7", "sha": "f0acac8efb3021b0f6a7b13b42d033d86e076a4b", "type": "file", "size": 5, "encoding": "base64", "content": "amZrc2o=" } ] } ``` ## 获取仓库代码目录 获取仓库代码目录 > 示例: ```shell curl -X GET \ -d "ref=develop" \ http://localhost:3000//api/jasder/jasder_test/entries.json ``` ```javascript await octokit.request('GET /api/jasder/jasder_test/entries.json') ``` ### HTTP 请求 `GET /api/:owner/:repo/entries.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | |ref |否| | string |分支名称、tag名称或是提交记录id,默认为master分支 | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |last_commit |object | |-- commit |object | |id |int |id | |name |string|文件夹或文件名称| |path |string|文件夹或文件相对路径| |type |string|文件类型, file:文件,dir:文件目录 |size |int|文件夹或文件大小 单位B |content |string|文件内容 |target |string|标签 > 返回的JSON示例: ```json { "last_commit": { "commit": { "sha": "3f2de4f78d2d7050486535082cd11cdfc9f3679e", "url": "http://localhost:3003//api/repositories/api-cloud-platform/commits/3f2de4f78d2d7050486535082cd11cdfc9f3679e", "message": "update README.md.", "author": { "name": "Gitee", "email": "noreply@gitee.com", "date": "2020-03-02T20:23:18+08:00" }, "committer": { "name": "Gitee", "email": "noreply@gitee.com", "date": "2020-03-02T20:23:18+08:00" }, "timestamp": 1583151798, "time_from_now": "3个月前" }, "author": null, "committer": null }, "entries": [ { "name": "ace-gate", "path": "ace-gate", "sha": "c83f85fc63b14edcd6fc502eee9996f5a9993eca", "type": "dir", "size": 0, "content": null, "target": null, "commit": { "message": "v2.9 升级alibaba组件release版本\n", "sha": "6117eaab86f71115f42f2a46ff1683015cda798d", "created_at": "1970-01-01 08:00", "time_from_now": "1年前", "created_at_unix": null } } ] } ``` ## 获取仓库代码子目录或者文件 获取仓库代码子目录或者文件 > 示例: ```shell curl -X GET \ -d "ref=master" \ -d "filepath=file" \ http://localhost:3000//api/jasder/jasder_test/sub_entries.json ``` ```javascript await octokit.request('GET /api/jasder/jasder_test/sub_entries.json') ``` ### HTTP 请求 `GET /api/:owner/:repo/sub_entries.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | |filepath |是|string |文件夹、文件的相对路径 | |ref |否| | string |分支名称、tag名称或是提交记录id,默认为master分支 | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |id |int |id | |name |string|文件夹或文件名称| |path |string|文件夹或文件相对路径| |type |string|文件类型, file:文件,dir:文件目录| |size |int|文件夹或文件大小 单位KB| |content |string|文件内容,| |target |string|标签| |url |string|文件访问链接,带分支| |html_url |string|文件访问链接,未标识分支| |git_url |string|文件夹或文件的git仓库访问链接| |download_url |string|文件下载、文件内容访问链接| > 返回的JSON示例: ```json [ { "name": "build.rc", "path": "lib/build.rc", "type": "", "size": 1268, "content": null, "target": null, "url": "http://localhost:3003/api/v1/repos/18816895620/mirror_demo/contents/lib/build.rc?ref=master", "html_url": "http://localhost:3003/18816895620/mirror_demo/src/branch/master/lib/build.rc", "git_url": "http://localhost:3003/api/v1/repos/18816895620/mirror_demo/git/blobs/191fcf1a63b3777e2977fcede7dd5309efdd70fe", "download_url": null } ] ``` ## 获取仓库README文件 获取仓库README文件 > 示例: ```shell curl -X GET \ -d "ref=master" \ -d "filepath=lib" \ http://localhost:3000/api/yystopf/csfjkkj/readme.json ``` ```javascript await octokit.request('GET /api/yystopf/csfjkkj/readme.json') ``` ### HTTP 请求 `GET /api/:owner/:repo/readme.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | |ref |否| | string |分支名称、tag名称或是提交记录id,默认为默认分支 | |filepath |否| | string |子目录名称,默认为空 | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |type |string|文件类型, file:文件,dir:文件目录 |encoding |string |编码 | |size |int|文件夹或文件大小 单位B |name |string|文件夹或文件名称| |path |string|文件夹或文件相对路径| |content |string|文件内容 |sha |string|文件commitid > 返回的JSON示例: ```json { "type": "file", "encoding": "base64", "size": 24, "name": "README.md", "path": "lib/README.md", "content": "ZGZhc2RhZGpmIGRrZnNsCgpzZGZkZnMK", "sha": "860962cd21c60b1a9e07d723080c87c32c18d44a" } ``` ## 获取文件树列表 根据分支、标签、commit ID获取仓库文件树列表 > 示例: ```shell curl -X GET \ -d "recursive=true" \ -d "page=1" \ -d "limit=1" \ http://localhost:3000/api/v1/yystopf/csfjkkj/git/trees/80dd40214a58622312393b2ae693756a4781fab2.json ``` ```javascript await octokit.request('GET /api/v1/yystopf/csfjkkj/git/trees/80dd40214a58622312393b2ae693756a4781fab2.json') ``` ### HTTP 请求 `GET /api/v1/:owner/:repo/git/trees/:sha.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| | string |用户登录名 | |repo |是| | string |项目标识identifier | |sha |是| | string |分支名称、tag名称或是提交记录id | |recursive|否| | bool |是否显示目录| |page |否|1 | int |页码| |limit |否|15| int |分页个数| ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |total_count |int |文件树数量| |sha |string |查询分支、标签、commit_id最后一次提交的ID | |entries.name |string |文件树名称| |entries.mode |string |文件树权限| |entries.type |string |文件树类型, file:文件,dir: 文件夹| |entries.size |int |文件树大小| |entries.sha |string |文件树commit_ID| > 返回的JSON示例: ```json { "total_count": 13, "sha": "80dd40214a58622312393b2ae693756a4781fab2", "entries": [ { "name": "README.md", "mode": "100644", "type": "file", "size": 14, "sha": "b2f7b457fd8ca55f2274032cbb2abcb7dd8cd57e" } ] } ``` ## 获取仓库blobs内容 根据commit ID获取仓库blobs内容 > 示例: ```shell curl -X GET http://localhost:3000/api/v1/yystopf/csfjkkj/git/blobs/80dd40214a58622312393b2ae693756a4781fab2.json ``` ```javascript await octokit.request('GET /api/v1/yystopf/csfjkkj/git/blobs/80dd40214a58622312393b2ae693756a4781fab2.json') ``` ### HTTP 请求 `GET /api/v1/:owner/:repo/git/blobs/:sha.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner|是| | string |用户登录名 | |repo |是| | string |项目标识identifier | |sha |是| | string |提交记录id | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |sha |string |提交ID | |size |int |blobs大小| |encoding |string |内容编码模式| |content |string |blobs内容| > 返回的JSON示例: ```json { "sha": "80dd40214a58622312393b2ae693756a4781fab2", "size": 247, "encoding": "base64", "content": "dHJlZSAyN2JjYjI2ZDQ5YmU1M2RmOGZmYTk5NDc3MjRkYmI3YzIzZWI4MjY4CnBhcmVudCA3ZTRkOGJiM2MyOGUyNGQ0Y2Q2YjIwNWYyZWVkMzI1MTNlOTM3NTI0CmF1dGhvciB5eXN0b3BmIDx5eXN0b3BmQDE2My5jb20+IDE2NTc3MDYwNTUgKzAwMDAKY29tbWl0dGVyIHl5c3RvcGYgPHl5c3RvcGZAMTYzLmNvbT4gMTY1NzcwNjA1NSArMDAwMAoKeOaLn+WingoKU2lnbmVkLW9mZi1ieTogeXlzdG9wZiA8eXlzdG9wZkAxNjMuY29tPg==" } ``` ## 获取仓库提交列表 根据分支名、标签、commit ID来获取提交列表 > 示例: ```shell curl -X GET \ -d "sha=master" \ -d "page=1" \ -d "limit=1" \ http://localhost:3000/api/v1/yystopf/csfjkkj/commits.json ``` ```javascript await octokit.request('GET /api/v1/yystopf/csfjkkj/commits.json') ``` ### HTTP 请求 `GET /api/v1/:owner/:repo/commits.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner|是| | string |用户登录名 | |repo |是| | string |项目标识identifier | |sha |否| | string |分支名、标签名或Commit ID| |page |否| | int |页码| |limit|否| | int |每页数量| ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |total_count|int|提交总数| |commits.sha|string|提交ID| |commits.author|object|提交作者| |commits.committer|object|提交者| |commits.commit_message|string|提交信息| |commits.parent_shas|array|提交父节点ID| |commits.files|array|提交文件| |commits.commit_date|string|提交日期| |commits.commit_time|string|提交时间| |commits.branch|string|提交分支| > 返回的JSON示例: ```json { "total_count": 12, "commits": [ { "sha": "86c62a1e91c07b58b8aa6c89b94856d89c0f7e55", "author": { "id": null, "login": "viletyy", "name": "viletyy", "type": null, "image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png" }, "committer": { "id": null, "login": "viletyy", "name": "viletyy", "type": null, "image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png" }, "commit_message": "fix\n", "parent_shas": [ "411e4d259785241f1bd14faf99ca24fd1b802f2a" ], "files": [ "hd.txt" ], "commit_date": "2022-07-05", "commit_time": "2022-07-05 11:00:45", "branch": "hh_ceshi" } ] } ``` ## 获取单个提交的blame信息 根据commit ID获取blame信息 > 示例: ```shell curl -X GET http://localhost:3000/api/v1/yystopf/csfjkkj/commits/80dd40214a58622312393b2ae693756a4781fab2/diff.json ``` ```javascript await octokit.request('GET /api/v1/yystopf/csfjkkj/commits/80dd40214a58622312393b2ae693756a4781fab2/diff.json') ``` ### HTTP 请求 `GET /api/v1/:owner/:repo/commits/:sha/diff.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner|是| | string |用户登录名 | |repo |是| | string |项目标识identifier | |sha |是| | string |提交记录id | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |file_nums|int|文件数量| |total_addition|int|新增行数| |total_deletion|int|删除行数| |files.name|string|文件名称| |files.oldname|string|文件修改前名称| |files.addition|int|文件新增行数| |files.deletion|int|文件删除行数| |files.type|int|文件类型 1: 新增 2: 更改 3: 删除 4: 重命名 5: 复制| |files.is_created|bool|是否为新建文件| |files.is_deleted|bool|是否为删除文件| |files.is_bin|bool|是否为二进制文件| |files.is_lfs_file|bool|| |files.is_renamed|bool|是否重命名| |files.is_ambiguous|bool|| |files.is_submodule|bool|是否为子模块| |files.sections.file_name|string|文件名称| |files.sections.name|string|| |files.sections.lines.left_index|int|| |files.sections.lines.right_index|int|| |files.sections.lines.match|int|| |files.sections.lines.type|int|| |files.sections.lines.content|string|| |files.sections.lines.section_path|string|| |files.sections.lines.section_last_left_index|int|| |files.sections.lines.section_last_right_index|int|| |files.sections.lines.section_left_index|int|| |files.sections.lines.section_right_index|int|| |files.sections.lines.section_left_hunk_size|int|| |files.sections.lines.section_right_hunk_size|int|| > 返回的JSON示例: ```json { "file_nums": 1, "total_addition": 1, "total_deletion": 0, "files": [ { "name": "xinzeng3", "oldname": "xinzeng3", "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": "xinzeng3", "name": "", "lines": [ { "left_index": 0, "right_index": 0, "match": 0, "type": 4, "content": "@@ -0,0 +1 @@", "section_path": "xinzeng3", "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 } ] } ``` ## 获取单个文件的blame信息 根据分支、标签、commitID获取某个文件的blame信息 > 示例: ```shell curl -X GET \ -d "sha=master" \ -d "filepath=hd.txt" \ http://localhost:3000/api/v1/yystopf/csfjkkj/blame.json ``` ```javascript await octokit.request('GET /api/v1/yystopf/csfjkkj/blame.json') ``` ### HTTP 请求 `GET /api/v1/:owner/:repo/blame.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| | string |用户登录名 | |repo |是| | string |项目标识identifier | |sha |是| | string |分支、标签或提交记录id | |filepath|是| | string |文件路径| ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |file_size|int|文件大小| |file_name|string|文件名称| |num_lines|int|文件总行数| |blame_parts.commit|object|提交| |blame_parts.current_number|int|当前行数| |blame_parts.effect_line|int|影响的行数| |blame_parts.lines|array|行内容| > 返回的JSON示例: ```json { "file_size": 32, "file_name": "hd.txt", "num_lines": 12, "blame_parts": [ { "commit": { "sha": "40f76e80bf5bc41fcc94c28ca8a6eab506c15215", "author": { "id": null, "login": "viletyy", "name": "viletyy", "type": null, "image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png" }, "committer": { "id": null, "login": "viletyy", "name": "viletyy", "type": null, "image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png" }, "commit_message": "fix\n", "authored_time": "2022-07-04 18:41:25", "committed_time": "2022-07-04 18:41:25", "created_time": "2022-07-04 18:41:25" }, "current_number": 1, "effect_line": 5, "lines": [ "dkfj", "s", "324", "234", "2" ] }, { "commit": { "sha": "86c62a1e91c07b58b8aa6c89b94856d89c0f7e55", "author": { "id": null, "login": "viletyy", "name": "viletyy", "type": null, "image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png" }, "committer": { "id": null, "login": "viletyy", "name": "viletyy", "type": null, "image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png" }, "commit_message": "fix\n", "authored_time": "2022-07-05 11:00:45", "committed_time": "2022-07-05 11:00:45", "created_time": "2022-07-05 11:00:45" }, "current_number": 6, "effect_line": 1, "lines": [ "dd" ] }, { "commit": { "sha": "40f76e80bf5bc41fcc94c28ca8a6eab506c15215", "author": { "id": null, "login": "viletyy", "name": "viletyy", "type": null, "image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png" }, "committer": { "id": null, "login": "viletyy", "name": "viletyy", "type": null, "image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png" }, "commit_message": "fix\n", "authored_time": "2022-07-04 18:41:25", "committed_time": "2022-07-04 18:41:25", "created_time": "2022-07-04 18:41:25" }, "current_number": 7, "effect_line": 3, "lines": [ "23", "4", "23" ] }, { "commit": { "sha": "86c62a1e91c07b58b8aa6c89b94856d89c0f7e55", "author": { "id": null, "login": "viletyy", "name": "viletyy", "type": null, "image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png" }, "committer": { "id": null, "login": "viletyy", "name": "viletyy", "type": null, "image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png" }, "commit_message": "fix\n", "authored_time": "2022-07-05 11:00:45", "committed_time": "2022-07-05 11:00:45", "created_time": "2022-07-05 11:00:45" }, "current_number": 10, "effect_line": 1, "lines": [ "s1" ] }, { "commit": { "sha": "40f76e80bf5bc41fcc94c28ca8a6eab506c15215", "author": { "id": null, "login": "viletyy", "name": "viletyy", "type": null, "image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png" }, "committer": { "id": null, "login": "viletyy", "name": "viletyy", "type": null, "image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png" }, "commit_message": "fix\n", "authored_time": "2022-07-04 18:41:25", "committed_time": "2022-07-04 18:41:25", "created_time": "2022-07-04 18:41:25" }, "current_number": 11, "effect_line": 1, "lines": [ "" ] } ] } ``` ## 获取比较提交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|是否为LFS文件| |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|文件变更之后的行数(及当前页面编辑器显示的总行数)| |diff.files.is_incomplete|bool|是否不完整| |diff.files.is_incomplete_line_too_long|bool|文件是否不完整是因为太长了| |diff.files.is_protected|bool|文件是否被保护| > 返回的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 ", "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 } ] } } ``` ## 获取仓库webhooks列表 获取仓库webhooks列表 > 示例: ```shell curl -X GET \ http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json ``` ```javascript await octokit.request('GET /api/v1/yystopf/ceshi/webhooks.json') ``` ### HTTP 请求 `GET /api/v1/:owner/:repo/webhooks.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |id |int |id | |url |string|地址| |http_method |string|请求方式| |is_active |bool |是否激活| |last_status |string|最后一次推送的状态| |create_time |string|创建时间| > 返回的JSON示例: ```json { "total_count": 4, "webhooks": [ { "id": 2, "url": "https://oapi.dingtalk.com/robot/send?access_token=7e1e19d0eddb6a5e33c5c2c4e66f4c88f9437184b9ed2c2653194c6374c7d513", "http_method": "", "is_active": true, "last_status": "succeed", "create_time": "2021-07-12 10:50:07" }, { "id": 3, "url": "http://localhost:3000", "http_method": "GET", "is_active": true, "last_status": "succeed", "create_time": "2021-07-26 10:03:45" }, { "id": 4, "url": "http://localhost:10081", "http_method": "POST", "is_active": true, "last_status": "waiting", "create_time": "2021-07-26 16:56:53" }, { "id": 5, "url": "http://localhost:3001", "http_method": "POST", "is_active": true, "last_status": "fail", "create_time": "2021-07-26 16:58:23" } ] } ``` ## 获取仓库单个webhook 获取仓库单个webhook > 示例: ```shell curl -X GET \ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3.json ``` ```javascript await octokit.request('GET /api/v1/yystopf/ceshi/webhooks/3.json') ``` ### HTTP 请求 `GET /api/v1/:owner/:repo/webhooks/:id.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | |id |是||integer|webhook ID| ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |id |int |id | |url |string|地址| |content_type |string|POST Content Type| |http_method |string|请求方式| |secret| |string|密钥| |active |bool |是否激活| |branch_filter |string|分支过滤| |events |string|触发条件| |create_at |string|创建时间| 参数| 含义| --------- | ------- | ------- | |create|创建分支或标签| |delete|分支或标签删除| |push|git仓库推送| |pull_request|合并请求| |pull_request_assign|合并请求被指派| |pull_request_review_approved|合并请求被批准| |pull_request_review_rejected|合并请求被拒绝| > 返回的JSON示例: ```json { "id": 3, "http_method": "GET", "content_type": "form", "url": "http://localhost:3000", "active": true, "create_at": "2021-07-26 10:03", "branch_filter": "*", "events": [ "create", "delete", "push", "pull_request", "pull_request_assign", ] } ``` ## 添加仓库webhook 添加仓库webhook > 示例: ```shell curl -X POST \ http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json ``` ```javascript await octokit.request('POST /api/v1/yystopf/ceshi/webhooks.json') ``` ### HTTP 请求 `POST /api/v1/:owner/:repo/webhooks.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| | string |用户登录名 | |repo |是| | string |项目标识identifier | |webhook.url |是| | string |目标url | |webhook.http_method |是| | string | http方法, POST和GET | |webhook.content_type |是| | string | POST Content Type | |webhook.secret |否| | string |密钥文本| |webhook.active |是| | bool | 是否激活| |webhook.branch_filter|否| |string|分支过滤| |webhook.events |否| |array|触发事件| |webhook.type |否| gitea |string| hook类型,gitea slack discord dingtalk telegram msteams feishu matrix jianmu| 触发事件字段说明 参数| 含义| --------- | ------- | ------- | |create|创建分支或标签| |delete|分支或标签删除| |push|git仓库推送| |pull_request|合并请求| |pull_request_assign|合并请求被指派| |pull_request_review_approved|合并请求被批准| |pull_request_review_rejected|合并请求被拒绝| > 请求的JSON示例: ```json { "active": true, "content_type": "json", "http_method": "GET", "secret": "123456", "url": "http://localhost:10000", "branch_filter": "*", "events": ["push"] } ``` ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |id |int |id | |url |string|地址| |content_type |string|POST Content Type| |is_active |bool |是否激活| |type |string|类型| |events | array|触发事件 | |create_time |string|创建时间| > 返回的JSON示例: ```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 > 示例: ```shell curl -X PATCH \ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json ``` ```javascript await octokit.request('PATCH /api/v1/yystopf/ceshi/webhooks/7.json') ``` ### HTTP 请求 `PATCH /api/v1/:owner/:repo/webhooks/68.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| | string |用户登录名 | |repo |是| | string |项目标识identifier | |id |是| | string |webhook id | |webhook.url |是| | string |目标url | |webhook.http_method |是| | string | http方法, POST和GET | |webhook.content_type |是| | string | POST Content Type | |webhook.secret |否| | string |密钥文本| |webhook.active |是| | bool | 是否激活| |webhook.branch_filter|否| |string|分支过滤| |webhook.events |否| |array|触发事件| 触发事件字段说明 参数| 含义| --------- | ------- | ------- | |create|创建分支或标签| |delete|分支或标签删除| |push|git仓库推送| |pull_request|合并请求| |pull_request_assign|合并请求被指派| |pull_request_review_approved|合并请求被批准| |pull_request_review_rejected|合并请求被拒绝| > 请求的JSON示例: ```json { "active": true, "content_type": "json", "http_method": "GET", "secret": "123456", "url": "http://localhost:10000", "branch_filter": "*", "events": ["push"] } ``` ### 返回字段说明: > 返回的JSON示例: ```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 > 示例: ```shell curl -X DELETE \ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json ``` ```javascript await octokit.request('DELETE /api/v1/yystopf/ceshi/webhooks/7.json') ``` ### HTTP 请求 `DELETE /api/v1/:owner/:repo/webhooks/:id.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| | string |用户登录名 | |repo |是| | string |项目标识identifier | |id |是| | string |webhook id | ### 返回字段说明: > 返回的JSON示例: ```json { "status": 0, "message": "success" } ``` ## 获取仓库webhook的历史推送列表 获取仓库webhook的历史推送列表 > 示例: ```shell curl -X GET \ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/hooktasks.json ``` ```javascript await octokit.request('GET /api/v1/yystopf/ceshi/webhooks/3/hooktasks.json') ``` ### HTTP 请求 `GET /api/v1/:owner/:repo/webhooks/:id/hooktasks.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | |id |是| |integer |webhook ID| ### 返回字段说明: 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |id |int |id | |uuid |string|推送uuid| |type |string|类型| |is_succeed |bool|是否推送成功| |is_delivered |bool|是否完成推送| |payload_content |json|请求主体内容| |request_content |json|请求内容,头部等等| |reponse_content |json|响应内容,状态,头部,主体等等| |delivered_time |string|推送时间| > 返回的JSON示例: ```json { "total_count": 6, "hooktasks": [ { "id": 20, "type": "gitea", "uuid": "99aa2c23-6884-4c44-9020-5469320aa408", "is_succeed": true, "is_delivered": true, "payload_content": { "secret": "123456", "ref": "refs/heads/master", "before": "feb48e31362787a7620b53d4df3c4effddbb6f0b", "after": "feb48e31362787a7620b53d4df3c4effddbb6f0b", "compare_url": "", "commits": [ { "id": "feb48e31362787a7620b53d4df3c4effddbb6f0b", "message": "fix\n", "url": "http://localhost:10081/yystopf/ceshi/commit/feb48e31362787a7620b53d4df3c4effddbb6f0b", "author": { "name": "viletyy", "email": "yystopf@163.com", "username": "root" }, "committer": { "name": "viletyy", "email": "yystopf@163.com", "username": "root" }, "verification": { "verified": false, "reason": "gpg.error.not_signed_commit", "signature": "", "signer": null, "payload": "" }, "timestamp": "2021-07-26T13:52:13+08:00", "added": null, "removed": null, "modified": null } ], "head_commit": null, "repository": { "id": 2, "owner": { "id": 3, "login": "yystopf", "full_name": "", "email": "yystopf@forge.com", "avatar_url": "http://localhost:10081/user/avatar/yystopf/-1", "language": "zh-CN", "is_admin": true, "last_login": "2021-07-21T18:38:21+08:00", "created": "2021-06-03T14:50:25+08:00", "username": "yystopf" }, "name": "ceshi", "full_name": "yystopf/ceshi", "description": "", "empty": false, "private": false, "fork": false, "template": false, "parent": null, "mirror": false, "size": 3846, "html_url": "http://localhost:10081/yystopf/ceshi", "ssh_url": "virus@localhost:10081:yystopf/ceshi.git", "clone_url": "http://localhost:10081/yystopf/ceshi.git", "original_url": "", "website": "", "stars_count": 0, "forks_count": 1, "watchers_count": 1, "open_issues_count": 0, "open_pr_counter": 0, "release_counter": 0, "default_branch": "master", "archived": false, "created_at": "2021-06-03T15:15:30+08:00", "updated_at": "2021-07-26T13:52:16+08:00", "permissions": { "admin": false, "push": false, "pull": false }, "has_issues": true, "internal_tracker": { "enable_time_tracker": true, "allow_only_contributors_to_track_time": true, "enable_issue_dependencies": true }, "has_wiki": true, "has_pull_requests": true, "ignore_whitespace_conflicts": false, "allow_merge_commits": true, "allow_rebase": true, "allow_rebase_explicit": true, "allow_squash_merge": true, "avatar_url": "", "internal": false }, "pusher": { "id": 0, "login": "yystopf", "full_name": "", "email": "yystopf@forge.com", "avatar_url": "http://localhost:10081/user/avatar/yystopf/-1", "language": "", "is_admin": false, "last_login": "0001-01-01T00:00:00Z", "created": "2021-06-03T14:50:25+08:00", "username": "yystopf" }, "sender": { "id": 0, "login": "yystopf", "full_name": "", "email": "yystopf@forge.com", "avatar_url": "http://localhost:10081/user/avatar/yystopf/-1", "language": "", "is_admin": false, "last_login": "0001-01-01T00:00:00Z", "created": "2021-06-03T14:50:25+08:00", "username": "yystopf" } }, "request_content": { "headers": { "X-GitHub-Delivery": "99aa2c23-6884-4c44-9020-5469320aa408", "X-GitHub-Event": "push", "X-Gitea-Delivery": "99aa2c23-6884-4c44-9020-5469320aa408", "X-Gitea-Event": "push", "X-Gitea-Signature": "34a01edcd952ff6410ff6ebc946471161bde74aff86171f21621d2c2c4130f66", "X-Gogs-Delivery": "99aa2c23-6884-4c44-9020-5469320aa408", "X-Gogs-Event": "push", "X-Gogs-Signature": "34a01edcd952ff6410ff6ebc946471161bde74aff86171f21621d2c2c4130f66" } }, "response_content": { "status": 200, "headers": { "Cache-Control": "no-store, must-revalidate, private, max-age=0", "Content-Length": "2556", "Content-Type": "text/html; charset=utf-8", "Referrer-Policy": "strict-origin-when-cross-origin", "Set-Cookie": "__profilin=p%3Dt; path=/; HttpOnly", "Vary": "Origin", "X-Content-Type-Options": "nosniff", "X-Download-Options": "noopen", "X-Frame-Options": "SAMEORIGIN", "X-Miniprofiler-Ids": "9ynvpncz5xm0rpgorb5y,hgggd9mv6lr4a9drcrlr,j7zqlx2vy5aji2vtgoba,f1ktsmh3jxvq0z2hf612,mih3dvgvlqhi3zy8lf2x,5k1qbkvbnru8mye9cest,tj6ern8w6awqf2zsimbr,9isaehvubivd52wo5p9v,1rzfhtq1nhuwbgy9p76g,z0xzidzyywna0y7a69m0,hzoklky92ycjqt42gi0s,y0ai7y0t28mcn8x0py2x,322il7nadinp51mw2r5m,m6dukftfsh6tjcxzp1gq,667wlqbytfwbrirnmma1,jcehj3dl8lkw8gk510cr", "X-Miniprofiler-Original-Cache-Control": "max-age=0, private, must-revalidate", "X-Permitted-Cross-Domain-Policies": "none", "X-Request-Id": "08bff080-bbb5-4183-b845-81de3d47120a", "X-Runtime": "0.394766", "X-Xss-Protection": "1; mode=block" }, "body": "
\n" }, "delivered_time": "2021-07-28 11:47:29" } ] } ``` ## 仓库webhook测试推送 仓库webhook测试推送 > 示例: ```shell curl -X POST \ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/tests.json ``` ```javascript await octokit.request('POST /api/v1/yystopf/ceshi/webhooks/3/tests.json') ``` ### HTTP 请求 `POST /api/v1/:owner/:repo/webhooks/:id/tests.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| | string |用户登录名 | |repo |是| | string |项目标识identifier | |id |是| | integer|webhook ID| ### 返回字段说明: > 返回的JSON示例: ```json { "status": 0, "message": "success" } ```