# Fork 项目
如果使用 project_full_path,确保 project_full_path 编码过,例子:/api/v3/projects/tencent/code--> /api/v3/projects/tencent%2Fcode (/ 编码 %2F)
# 新建 Fork 项目
Fork 项目到其他的命名空间。 未指定 namespace_id 时,默认 fork 到用户自己的命名空间。指定了有权限的 namespace_id 时,则 fork 到指定的命名空间
POST /api/v3/projects/fork/:id
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer or string | 项目 ID 或 项目全路径 project_full_path |
| namespace_id | integer | 有权限的项目组或者命名空间 id |
返回值:
{
"id": 561,
"description": null,
"public": false,
"archived": false,
"visibility_level": 0,
"namespace": {
"created_at": "2017-01-29T07:49:48+0000",
"description": "git_user1",
"id": 2513,
"name": "git_user1",
"owner_id": 11323,
"path": "git_user1",
"updated_at": "2017-01-29T07:49:48+0000"
},
"owner": {
"id": 11323,
"username": "git_user1",
"web_url": "https://git.tencent.com/u/git_user1",
"name": "git_user1",
"state": "active",
"avatar_url": "git.tencent.com/uploads/user/avatar/11323/fec6c477729445df9a6e0a4a05b4a86c.png"
},
"name": "fork_project",
"name_with_namespace": "git_user1/fork_project",
"path": "fork_project",
"path_with_namespace": "git_user1/fork_project",
"default_branch": "master",
"ssh_url_to_repo": "git@git.tencent.com:git_user1/fork_project.git",
"http_url_to_repo": "http://git.tencent.com/git/git_user1/fork_project.git",
"https_url_to_repo": "https://git.tencent.com/git/git_user1/fork_project.git",
"web_url": "https://git.tencent.com/git_user1/fork_project",
"tag_list": [],
"issues_enabled": true,
"merge_requests_enabled": true,
"wiki_enabled": true,
"snippets_enabled": true,
"review_enabled": true,
"fork_enabled": false,
"tag_name_regex": null,
"tag_create_push_level": 30,
"created_at": "2017-08-14T06:29:25+0000",
"last_activity_at": "2017-08-14T06:29:25+0000",
"creator_id": 11323,
"avatar_url": "https://git.tencent.com/uploads/project/avatar/561",
"watchs_count": 1,
"stars_count": 0,
"forks_count": 0,
"config_storage": {
"limit_lfs_file_size": 500,
"limit_size": 100000,
"limit_file_size": 100,
"limit_lfs_size": 100000
},
"config_confidential": {
"level": -1,
"allow_ai_coding_tool": true
},
"forked_from_project": {
"path": "fork_project",
"path_with_namespace": "test-06/fork_project",
"name": "fork_project",
"id": 32811,
"name_with_namespace": "test-0607/fork_project"
},
"statistics": {
"commit_count": 0,
"repository_size": 0
}
}
# 删除 Fork 关系
删除 fork 的项目,删除 fork 关系。仅系统管理员可操作
DELETE /api/v3/projects/:id/fork
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer or string | 项目 ID 或 项目全路径 project_full_path |
返回值:
200或相关状态码
# 获取项目的 fork 列表
获取一个项目的 fork 列表,返回列表中的项目都是从指定项目 fork 而来,并且是当前用户有权限访问的项目,支持搜索、分页
GET /api/v3/projects/:id/forks
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | integer or string | 项目 ID 或 项目全路径 project_full_path |
| search | string(可选) | 搜索条件,模糊匹配path,name |
| archived | boolean(可选) | 归档状态,archived = true限制为查询归档项目,默认不区分归档状态 |
| order_by | string(可选) | 排序字段,允许按 id,name,path,created_at,updated_at,last_activity_at排序(默认created_at) |
| sort | string(可选) | 排序方式,允许asc,desc(默认 desc) |
| owned | boolean(可选) | 若为 true,返回的是当前用户个人 namespace 下的 project,以及 owner 为当前用户的 group 下的所有 project 的子集 |
| min_access_level | integer(可选) | 指定最小访问级别,返回的 project 列表中,当前用户的 project 访问级别大于或者等于指定值 |
| page | integer(可选) | 页数(默认值:1) |
| per_page | integer(可选) | 默认页面大小(默认值:20,最大值:100) |
返回值:
[
{
"id": 8922,
"description": null,
"public": false,
"archived": false,
"visibility_level": 0,
"namespace": {
"created_at": "2017-01-16T08:29:43+0000",
"description": "git_user1",
"id": 11323,
"name": "git_user1",
"owner_id": 11323,
"path": "git_user1",
"updated_at": "2017-01-16T08:29:43+0000"
},
"owner": {
"id": 11323,
"username": "git_user1",
"web_url": "https://git.tencent.com/u/git_user1",
"name": "git_user1",
"state": "active",
"avatar_url": "git.tencent.com/uploads/user/avatar/11323/a75ba2727c7a409cab1d15dd993149aa.jpg"
},
"name": "test-01",
"name_with_namespace": "git_user1/test-01",
"path": "test-01",
"path_with_namespace": "git_user1/test-01",
"default_branch": "master",
"ssh_url_to_repo": "git@git.tencent.com:git_user1/test-01.git",
"http_url_to_repo": "http://git.tencent.com/git_user1/test-01.git",
"https_url_to_repo": "https://git.tencent.com/git_user1/test-01.git",
"web_url": "https://git.tencent.com/git_user1/test-01",
"tag_list": [],
"issues_enabled": true,
"merge_requests_enabled": true,
"wiki_enabled": true,
"snippets_enabled": true,
"review_enabled": true,
"fork_enabled": false,
"tag_name_regex": null,
"tag_create_push_level": 30,
"created_at": "2017-08-13T07:37:14+0000",
"last_activity_at": "2017-08-13T07:37:14+0000",
"creator_id": 11323,
"avatar_url": "https://git.tencent.com/uploads/project/avatar/70703",
"watchs_count": 0,
"stars_count": 0,
"forks_count": 0,
"config_storage": {
"limit_lfs_file_size": 500,
"limit_size": 100000,
"limit_file_size": 100000,
"limit_lfs_size": 100000
},
"config_confidential": {
"level": -1,
"allow_ai_coding_tool": true
},
"forked_from_project": "Forked Project not found",
"statistics": {
"commit_count": 0,
"repository_size": 0
},
"permissions": {
"project_access": {
"access_level": null
},
"share_group_access": {
"access_level": null
},
"group_access": {
"access_level": 10
}
}
}
]