获取issue关联的分支列表¶
GET /api/v5/repos/{owner}/{repo}/issues/{number}/related_branches
该接口用于获取指定 issue 关联的分支列表,通过仓库所属空间地址、仓库路径和 Issue 编号进行查询,返回与该 issue 相关联的分支名称,响应体为字符串数组,其中每个元素对应一条分支名称。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(组织或个人的地址 path) |
repo |
path | string | 是 | 仓库路径(path) |
number |
path | string | 是 | Issue 编号(区分大小写,无需添加 # 号) |
响应参数¶
响应体是一个字符串数组,数组中的每个元素为一条与 issue 关联的分支名称。
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
| (响应体) | string[] | 是 | 否 | 与 issue 关联的分支名称列表 |
失败响应¶
该接口无业务失败响应;请求失败时返回对应的 HTTP 状态码及错误信息,错误字段名以后端实际返回为准。
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
404 |
资源不存在(Not found) |
500 |
系统内部错误(Internal server error) |
请求示例¶
参数说明¶
示例中的占位符说明如下:
<owner>— 替换为仓库所属空间地址(组织或个人的地址 path);<repo>— 替换为仓库路径(path);<number>— 替换为 Issue 编号(区分大小写,无需添加 # 号)。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/issues/<number>/related_branches' \
-H 'Accept: application/json'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const owner = "<owner>";
const repo = "<repo>";
const number = "<number>";
const response = await fetch(
`https://api.atomgit.com/api/v5/repos/${owner}/${repo}/issues/${number}/related_branches`,
{ headers: { "Accept": "application/json" } }
);
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
owner = "<owner>"
repo = "<repo>"
number = "<number>"
resp = requests.get(
f"https://api.atomgit.com/api/v5/repos/{owner}/{repo}/issues/{number}/related_branches",
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
错误码¶
| 错误码 | 说明 |
|---|---|
404 |
资源不存在 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc