{{< details >}}

  • Tier: 基础版,专业版,旗舰版
  • Offering: JihuLab.com,私有化部署

{{< /details >}}

草稿注释是在合并请求中待处理的未发布评论。它们可以:

  • 开始一个讨论。
  • 作为回复继续现有的讨论。

在发布之前,草稿注释仅对作者可见。

列出所有合并请求草稿注释

获取单个合并请求的所有草稿注释的列表。

GET /projects/:id/merge_requests/:merge_request_iid/draft_notes
属性 类型 必需 描述
id integer 或 string 项目的 ID 或 URL 编码路径
merge_request_iid integer 项目合并请求的 IID
[
  {
    "id": 5,
    "author_id": 23,
    "merge_request_id": 11,
    "resolve_discussion": false,
    "discussion_id": null,
    "note": "Example title",
    "commit_id": null,
    "line_code": null,
    "position": {
      "base_sha": null,
      "start_sha": null,
      "head_sha": null,
      "old_path": null,
      "new_path": null,
      "position_type": "text",
      "old_line": null,
      "new_line": null,
      "line_range": null
    }
  }
]
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/14/merge_requests/11/draft_notes"

获取单个草稿注释

返回给定合并请求的单个草稿注释。

GET /projects/:id/merge_requests/:merge_request_iid/draft_notes/:draft_note_id
属性 类型 必需 描述
id integer 或 string 项目的 ID 或 URL 编码路径
draft_note_id integer 草稿注释的 ID
merge_request_iid integer 项目合并请求的 IID
[
  {
    "id": 5,
    "author_id": 23,
    "merge_request_id": 11,
    "resolve_discussion": false,
    "discussion_id": null,
    "note": "Example title",
    "commit_id": null,
    "line_code": null,
    "position": {
      "base_sha": null,
      "start_sha": null,
      "head_sha": null,
      "old_path": null,
      "new_path": null,
      "position_type": "text",
      "old_line": null,
      "new_line": null,
      "line_range": null
    }
  }
]
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/14/merge_requests/11/draft_notes/5"

创建草稿注释

为给定的合并请求创建草稿注释。

POST /projects/:id/merge_requests/:merge_request_iid/draft_notes
属性 类型 必需 描述
id integer 或 string 项目的 ID 或 URL 编码路径
merge_request_iid integer 项目合并请求的 IID
note string 笔记的内容
commit_id string 关联草稿注释的提交 SHA
in_reply_to_discussion_id string 草稿注释回复的讨论 ID
resolve_discussion boolean 关联的讨论是否应该解决
position[base_sha] string 源分支中的基础提交 SHA
position[head_sha] string 合并请求的 HEAD 引用 SHA
position[start_sha] string 目标分支中的提交引用 SHA
position[new_path] string 是 (如果位置类型是 text) 变更后的文件路径
position[old_path] string 是 (如果位置类型是 text) 变更前的文件路径
position[position_type] string 位置引用的类型。允许值:textimagefilefile极狐GitLab 16.4 中引入
position hash 创建差异笔记时的位置
position[new_line] integer 对于 text 差异笔记,变更后的行号
position[old_line] integer 对于 text 差异笔记,变更前的行号
position[line_range] hash 多行差异笔记的行范围
position[width] integer 对于 image 差异笔记,图像的宽度
position[height] integer 对于 image 差异笔记,图像的高度
position[x] float 对于 image 差异笔记,X 坐标
position[y] float 对于 image 差异笔记,Y 坐标
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/14/merge_requests/11/draft_notes?note=note"

修改现有草稿注释

修改给定合并请求的草稿注释。

PUT /projects/:id/merge_requests/:merge_request_iid/draft_notes/:draft_note_id
属性 类型 必需 描述
id integer 或 string 项目的 ID 或 URL 编码路径
draft_note_id integer 草稿注释的 ID
merge_request_iid integer 项目合并请求的 IID
note string 笔记的内容
position[base_sha] string 源分支中的基础提交 SHA
position[head_sha] string 合并请求的 HEAD 引用 SHA
position[start_sha] string 目标分支中的提交引用 SHA
position[new_path] string 是 (如果位置类型是 text) 变更后的文件路径
position[old_path] string 是 (如果位置类型是 text) 变更前的文件路径
position[position_type] string 位置引用的类型。允许值:textimagefilefile极狐GitLab 16.4 中引入
position hash 创建差异笔记时的位置
position[new_line] integer 对于 text 差异笔记,变更后的行号
position[old_line] integer 对于 text 差异笔记,变更前的行号
position[line_range] hash 多行差异笔记的行范围
position[width] integer 对于 image 差异笔记,图像的宽度
position[height] integer 对于 image 差异笔记,图像的高度
position[x] float 对于 image 差异笔记,X 坐标
position[y] float 对于 image 差异笔记,Y 坐标
curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/14/merge_requests/11/draft_notes/5"

删除草稿注释

删除给定合并请求的现有草稿注释。

DELETE /projects/:id/merge_requests/:merge_request_iid/draft_notes/:draft_note_id
属性 类型 必需 描述
draft_note_id integer 草稿注释的 ID
id integer 或 string 项目的 ID 或 URL 编码路径
merge_request_iid integer 项目合并请求的 IID
curl --request DELETE \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/14/merge_requests/11/draft_notes/5"

发布草稿注释

发布给定合并请求的现有草稿注释。

PUT /projects/:id/merge_requests/:merge_request_iid/draft_notes/:draft_note_id/publish
属性 类型 必需 描述
draft_note_id integer 草稿注释的 ID
id integer 或 string 项目的 ID 或 URL 编码路径
merge_request_iid integer 项目合并请求的 IID
curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/14/merge_requests/11/draft_notes/5/publish"

发布所有待处理的草稿注释

批量发布属于用户的给定合并请求的所有现有草稿注释。

POST /projects/:id/merge_requests/:merge_request_iid/draft_notes/bulk_publish
属性 类型 必需 描述
id integer 或 string 项目的 ID 或 URL 编码路径
merge_request_iid integer 项目合并请求的 IID
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/14/merge_requests/11/draft_notes/bulk_publish"