跳转至

获取企业 issue 关联的 Pull Requests

GET /api/v5/enterprises/{enterprise}/issues/{number}/pull_requests

该接口用于获取指定企业下与某个 issue 关联的所有 Pull Requests,通过企业路径与 issue 全局 id 进行查询,返回包含 PR 序号、标题、状态、分支信息等详细字段的 Pull Request 数组。

访问令牌支持说明

  • AtomGit 用户访问令牌(AtomGit user access tokens)

是否允许匿名访问

此接口允许匿名访问

请求参数

参数名 位置 类型 必填 说明
enterprise path string 是 企业的路径(path/login),即企业所属空间地址(企业、组织或个人的地址path)
number path integer 是 issue 全局 id(唯一 id)

响应参数

响应为 Pull Request 对象数组(array<object>),每个元素为一条关联的 Pull Request。

字段 类型 必返 可为空 说明
number integer 否 是 PR 序号
html_url string 否 是 Pull 页面地址
url string 否 是 Pull Request 的 API 地址
close_related_issue integer 否 是 合并后关闭关联的 issue
prune_branch boolean 否 是 是否强制删除源分支
draft boolean 否 是 是否草稿状态
labels array 否 是 标签列表
user object 否 是 发起人(PR 作者)信息
assignees array 否 是 评审人列表
testers array 否 是 测试人列表
head object 否 是 源分支信息
base object 否 是 目标分支信息
id integer 否 是 PR 全局 id
iid integer 否 是 PR 在项目内的编号
project_id integer 否 是 项目 id
title string 否 是 PR 标题
body string 否 是 PR 描述
state string 否 是 PR 状态(如 merged、open 等)
assignees_number integer 否 是 评审人数量
testers_number integer 否 是 测试人数量
created_at string 否 是 创建时间
updated_at string 否 是 更新时间
merged_at string 否 是 合并时间
closed_at string 否 是 关闭时间
target_branch string 否 是 目标分支
source_branch string 否 是 源分支
source_project_id integer 否 是 源项目 id
force_remove_source_branch boolean 否 是 是否强制删除源分支
web_url string 否 是 Pull Request 页面地址
merge_request_type string 否 是 合并请求类型
review_mode string 否 是 评审模式
added_lines integer 否 是 新增行数
removed_lines integer 否 是 删除行数
diff_refs object 否 是 差异引用
notes integer 否 是 评论/备注数量
pipeline_status string 否 是 流水线状态
pipeline_status_with_code_quality string 否 是 含代码质量检查的流水线状态
source_git_url string 否 是 源仓库 git 地址
can_merge_check boolean 否 是 是否允许合并检查
mergeable boolean 否 是 是否可以合并
locked boolean 否 是 是否锁定
diff_url string 否 是 diff 地址
patch_url string 否 是 patch 地址
commits_url string 否 是 提交列表地址
comments_url string 否 是 评论列表地址
issue_url string 否 是 关联 issue 列表地址

user 对象

字段 类型 必返 可为空 说明
user.id string 否 是 用户 id
user.login string 否 是 登录名
user.name string 否 是 用户名
user.state string 否 是 用户状态(如 active)
user.email string 否 是 邮箱
user.name_cn string 否 是 中文名
user.html_url string 否 是 用户主页地址

head 对象

字段 类型 必返 可为空 说明
head.label string 否 是 源分支引用标签
head.ref string 否 是 源分支名
head.sha string 否 是 源分支提交 sha
head.user object 否 是 源分支用户信息
head.repo object 否 是 源仓库信息

base 对象

字段 类型 必返 可为空 说明
base.label string 否 是 目标分支引用标签
base.ref string 否 是 目标分支名
base.sha string 否 是 目标分支提交 sha
base.user object 否 是 目标分支用户信息
base.repo object 否 是 目标仓库信息

diff_refs 对象

字段 类型 必返 可为空 说明
diff_refs.base_sha string 否 是 目标分支提交 sha
diff_refs.head_sha string 否 是 源分支提交 sha
diff_refs.start_sha string 否 是 起始提交 sha

head.repo 对象(base.repo 结构相同)

字段 类型 必返 可为空 说明
*.repo.id integer 否 是 仓库 id
*.repo.full_path string 否 是 仓库完整路径
*.repo.full_name string 否 是 仓库完整名称
*.repo.human_name string 否 是 仓库展示名称
*.repo.name string 否 是 仓库名称
*.repo.path string 否 是 仓库路径
*.repo.description string 否 是 仓库描述
*.repo.owner object 否 是 仓库所有者信息
*.repo.assigner object 否 是 仓库指派者信息
*.repo.internal boolean 否 是 是否内部仓库
*.repo.html_url string 否 是 仓库地址

*.repo.owner 对象(*.repo.assigner 结构相同)

字段 类型 必返 可为空 说明
*.repo.owner.id string 否 是 用户 id
*.repo.owner.login string 否 是 登录名
*.repo.owner.name string 否 是 用户名
*.repo.owner.state string 否 是 用户状态
*.repo.owner.email string 否 是 邮箱
*.repo.owner.name_cn string 否 是 中文名
*.repo.owner.html_url string 否 是 用户主页地址

HTTP 响应状态码

状态码 说明
200 成功(OK)
401 需要认证(Requires authentication)
403 禁止访问(Forbidden)
404 请求路径不存在
429 请求过于频繁,触发限流
500 系统内部错误

请求示例

参数说明

<enterprise> 替换为企业路径(企业、组织或个人的地址 path); <number> 替换为 issue 全局 id。

该接口允许匿名访问,也可携带 AtomGit 用户访问令牌(以 ?access_token=<token> 追加到查询参数中)。

cURL

curl -X GET 'https://api.atomgit.com/api/v5/enterprises/<enterprise>/issues/<number>/pull_requests' \
  -H 'Accept: application/json'

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v5/enterprises/<enterprise>/issues/<number>/pull_requests", {
  headers: {
    "Accept": "application/json",
  },
});

if (!response.ok) {
  throw new Error(`请求失败: ${response.status}`);
}

const data = await response.json();
console.log(data);

Python

import requests

resp = requests.get(
    "https://api.atomgit.com/api/v5/enterprises/<enterprise>/issues/<number>/pull_requests",
    headers={
        "Accept": "application/json",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

响应示例

状态码: 200

[
  {
    "number": 1,
    "html_url": "https://api.atomgit.com/owner-test/wonderful1/merge_requests/1",
    "url": "https://api.atomgit.com/api/v5/repos/owner-test/wonderful1/pulls/1",
    "close_related_issue": 0,
    "prune_branch": false,
    "draft": false,
    "labels": [],
    "user": {
      "id": "654c61e5560ed95fd216cf31",
      "login": "csdn_fenglh",
      "name": "fenglh",
      "state": "active",
      "email": "",
      "name_cn": "",
      "html_url": "https://api.atomgit.com/csdn_fenglh"
    },
    "assignees": [],
    "testers": [],
    "head": {
      "label": "wonderful1-patch-1",
      "ref": "wonderful1-patch-1",
      "sha": "9931ba43e2c485741192d8e9a0b698fed79100f9",
      "user": {
        "id": "6638af02bbeee41d0fe74c35",
        "login": "malongge5",
        "name": "malongge5",
        "state": "active",
        "email": "malongge5@noreply.gitcode.com",
        "name_cn": "",
        "html_url": "https://api.atomgit.com/malongge5"
      },
      "repo": {
        "id": 686738,
        "full_path": "owner-test/wonderful1",
        "full_name": "owner-test/wonderful1",
        "human_name": "测试 / wonderful1",
        "name": "wonderful1",
        "path": "wonderful1",
        "description": "我的测试代码仓库",
        "owner": {
          "id": "6638af02bbeee41d0fe74c35",
          "login": "malongge5",
          "name": "malongge5",
          "state": "active",
          "email": "malongge5@noreply.gitcode.com",
          "name_cn": "",
          "html_url": "https://api.atomgit.com/malongge5"
        },
        "assigner": {
          "id": "6638af02bbeee41d0fe74c35",
          "login": "malongge5",
          "name": "malongge5",
          "state": "active",
          "email": "malongge5@noreply.gitcode.com",
          "name_cn": "",
          "html_url": "https://api.atomgit.com/malongge5"
        },
        "internal": false,
        "html_url": "https://api.atomgit.com/owner-test/wonderful1.git"
      }
    },
    "base": {
      "label": "abc",
      "ref": "abc",
      "sha": "44a8d3e1142468ab2db0fa8c3402a71ccf891572",
      "user": {
        "id": "6638af02bbeee41d0fe74c35",
        "login": "malongge5",
        "name": "malongge5",
        "state": "active",
        "email": "malongge5@noreply.gitcode.com",
        "name_cn": "",
        "html_url": "https://api.atomgit.com/malongge5"
      },
      "repo": {
        "id": 686738,
        "full_path": "owner-test/wonderful1",
        "full_name": "owner-test/wonderful1",
        "human_name": "测试 / wonderful1",
        "name": "wonderful1",
        "path": "wonderful1",
        "description": "我的测试代码仓库",
        "owner": {
          "id": "6638af02bbeee41d0fe74c35",
          "login": "malongge5",
          "name": "malongge5",
          "state": "active",
          "email": "malongge5@noreply.gitcode.com",
          "name_cn": "",
          "html_url": "https://api.atomgit.com/malongge5"
        },
        "assigner": {
          "id": "6638af02bbeee41d0fe74c35",
          "login": "malongge5",
          "name": "malongge5",
          "state": "active",
          "email": "malongge5@noreply.gitcode.com",
          "name_cn": "",
          "html_url": "https://api.atomgit.com/malongge5"
        },
        "internal": false,
        "html_url": "https://api.atomgit.com/owner-test/wonderful1.git"
      }
    },
    "id": 191980,
    "iid": 1,
    "project_id": 686738,
    "title": "hhhh",
    "body": "update: 更新文件 README.md ",
    "state": "merged",
    "assignees_number": 0,
    "testers_number": 0,
    "created_at": "2024-11-23T20:51:32+08:00",
    "updated_at": "2024-12-13T16:16:54+08:00",
    "merged_at": "2024-11-25T20:40:19+08:00",
    "closed_at": "",
    "target_branch": "abc",
    "source_branch": "wonderful1-patch-1",
    "source_project_id": 686738,
    "force_remove_source_branch": false,
    "web_url": "https://api.atomgit.com/owner-test/wonderful1/merge_requests/1",
    "merge_request_type": "MergeRequest",
    "review_mode": "approval",
    "added_lines": 2,
    "removed_lines": 2,
    "diff_refs": {
      "base_sha": "91a8edc0db6889fc7309d3306da7b12113e4a73f",
      "head_sha": "9931ba43e2c485741192d8e9a0b698fed79100f9",
      "start_sha": "91a8edc0db6889fc7309d3306da7b12113e4a73f"
    },
    "notes": 0,
    "pipeline_status": "",
    "pipeline_status_with_code_quality": "",
    "source_git_url": "ssh://git@atomgit.com:2222/owner-test/wonderful1.git",
    "can_merge_check": true,
    "mergeable": true,
    "locked": false,
    "diff_url": "https://api.atomgit.com/owner-test/wonderful1/merge_requests/1.diff",
    "patch_url": "https://api.atomgit.com/owner-test/wonderful1/merge_requests/1.patch",
    "commits_url": "https://api.atomgit.com/api/v5/repos/owner-test/wonderful1/pulls/1/commits",
    "comments_url": "https://api.atomgit.com/api/v5/repos/owner-test/wonderful1/pulls/1/comments",
    "issue_url": "https://api.atomgit.com/api/v5/repos/owner-test/wonderful1/pulls/1/issues"
  }
]

错误码

错误码 说明
401 未认证或凭证无效(缺少/无效的访问凭证)
404 请求路径不存在
405 请求方法不支持
429 请求过于频繁,触发限流
500 系统内部错误

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc