合并请求上下文提交 API
- Tier: 基础版, 专业版, 旗舰版
- Offering: JihuLab.com, 私有化部署
如果您的合并请求建立在之前的合并请求之上,您可能需要包含之前合并的提交以获得上下文。使用此 API 来为合并请求添加提交以获得更多上下文。
列出 MR 上下文提交
获取合并请求上下文提交的列表。
plaintextGET /projects/:id/merge_requests/:merge_request_iid/context_commits
参数:
| 属性 | 类型 | 必须 | 描述 |
|---|---|---|---|
| id | integer | 是 | 项目的 ID 或 URL 编码路径。 |
| merge_request_iid | integer | 是 | 合并请求的内部 ID。 |
json1[ 2 { 3 "id": "4a24d82dbca5c11c61556f3b35ca472b7463187e", 4 "short_id": "4a24d82d", 5 "created_at": "2017-04-11T10:08:59.000Z", 6 "parent_ids": null, 7 "title": "Update README.md to include `Usage in testing and development`", 8 "message": "Update README.md to include `Usage in testing and development`", 9 "author_name": "Example \"Sample\" User", 10 "author_email": "user@example.com", 11 "authored_date": "2017-04-11T10:08:59.000Z", 12 "committer_name": "Example \"Sample\" User", 13 "committer_email": "user@example.com", 14 "committed_date": "2017-04-11T10:08:59.000Z" 15 } 16]
创建 MR 上下文提交
创建合并请求上下文提交的列表。
plaintextPOST /projects/:id/merge_requests/:merge_request_iid/context_commits
参数:
| 属性 | 类型 | 必须 | 描述 |
|---|---|---|---|
| id | integer | 是 | 项目的 ID 或 URL 编码路径 |
| merge_request_iid | integer | 是 | 合并请求的内部 ID。 |
| commits | string array | 是 | 上下文提交的 SHA。 |
示例请求:
shellcurl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \ --header 'Content-Type: application/json' \ --data '{"commits": ["51856a574ac3302a95f82483d6c7396b1e0783cb"]}' \ --url "https://gitlab.example.com/api/v4/projects/15/merge_requests/12/context_commits"
示例响应:
json1[ 2 { 3 "id": "51856a574ac3302a95f82483d6c7396b1e0783cb", 4 "short_id": "51856a57", 5 "created_at": "2014-02-27T10:05:10.000+02:00", 6 "parent_ids": [ 7 "57a82e2180507c9e12880c0747f0ea65ad489515" 8 ], 9 "title": "Commit title", 10 "message": "Commit message", 11 "author_name": "Example User", 12 "author_email": "user@example.com", 13 "authored_date": "2014-02-27T10:05:10.000+02:00", 14 "committer_name": "Example User", 15 "committer_email": "user@example.com", 16 "committed_date": "2014-02-27T10:05:10.000+02:00", 17 "trailers": {}, 18 "web_url": "https://gitlab.example.com/project/path/-/commit/b782f6c553653ab4e16469ff34bf3a81638ac304" 19 } 20]
删除 MR 上下文提交
删除合并请求上下文提交的列表。
plaintextDELETE /projects/:id/merge_requests/:merge_request_iid/context_commits
参数:
| 属性 | 类型 | 必须 | 描述 |
|---|---|---|---|
| commits | string array | 是 | 上下文提交的 SHA。 |
| id | integer | 是 | 项目的 ID 或 URL 编码路径。 |
| merge_request_iid | integer | 是 | 合并请求的内部 ID。 |