<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Merge requests API > 原文:[https://docs.gitlab.com/ee/api/merge_requests.html](https://docs.gitlab.com/ee/api/merge_requests.html) * [List merge requests](#list-merge-requests) * [List project merge requests](#list-project-merge-requests) * [List group merge requests](#list-group-merge-requests) * [Get single MR](#get-single-mr) * [Get single MR participants](#get-single-mr-participants) * [Get single MR commits](#get-single-mr-commits) * [Get single MR changes](#get-single-mr-changes) * [List MR pipelines](#list-mr-pipelines) * [Create MR Pipeline](#create-mr-pipeline) * [Create MR](#create-mr) * [Update MR](#update-mr) * [Delete a merge request](#delete-a-merge-request) * [Accept MR](#accept-mr) * [Merge to default merge ref path](#merge-to-default-merge-ref-path) * [Cancel Merge When Pipeline Succeeds](#cancel-merge-when-pipeline-succeeds) * [Rebase a merge request](#rebase-a-merge-request) * [Comments on merge requests](#comments-on-merge-requests) * [List issues that will close on merge](#list-issues-that-will-close-on-merge) * [Subscribe to a merge request](#subscribe-to-a-merge-request) * [Unsubscribe from a merge request](#unsubscribe-from-a-merge-request) * [Create a todo](#create-a-todo) * [Get MR diff versions](#get-mr-diff-versions) * [Get a single MR diff version](#get-a-single-mr-diff-version) * [Set a time estimate for a merge request](#set-a-time-estimate-for-a-merge-request) * [Reset the time estimate for a merge request](#reset-the-time-estimate-for-a-merge-request) * [Add spent time for a merge request](#add-spent-time-for-a-merge-request) * [Reset spent time for a merge request](#reset-spent-time-for-a-merge-request) * [Get time tracking stats](#get-time-tracking-stats) * [Approvals](#approvals-starter) # Merge requests API[](#merge-requests-api "Permalink") 合并請求的每個 API 調用都必須經過驗證. **棄用** > `reference`響應屬性有利于已棄用`references` . >推出了[GitLab 12.6](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/20354)**注意** > `references.relative`相對于正在請求合并請求的組/項目. 當從其項目中獲取合并請求時> `relative`格式將與`short`格式相同,并且在跨組/項目進行請求時, `relative`格式應與`full`格式相同. ## List merge requests[](#list-merge-requests "Permalink") 在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13060) . 獲取所有通過身份驗證的用戶有權訪問的合并請求. 默認情況下,它僅返回當前用戶創建的合并請求. 要獲取所有合并請求,請使用參數`scope=all` . `state`參數可用于僅獲取具有給定狀態( `opened` , `closed` , `locked`或`merged` )或全部( `all` )的合并請求. 應該注意的是,通過`locked`進行搜索時,由于它是短暫的過渡狀態,因此幾乎不會返回任何結果. 分頁參數`page`和`per_page`可用于限制合并請求的列表. ``` GET /merge_requests GET /merge_requests?state=opened GET /merge_requests?state=all GET /merge_requests?milestone=release GET /merge_requests?labels=bug,reproduced GET /merge_requests?author_id=5 GET /merge_requests?author_username=gitlab-bot GET /merge_requests?my_reaction_emoji=star GET /merge_requests?scope=assigned_to_me GET /merge_requests?search=foo&in=title ``` Parameters: | Attribute | Type | Required | Description | ? | | --- | --- | --- | --- | --- | | `state` | string | no | 返回所有合并請求,或者僅返回已`opened` , `closed` , `locked`或`merged`請求 | ? | | `order_by` | string | no | 返回由`created_at`或`updated_at`字段排序的請求. 默認為`created_at` | ? | | `sort` | string | no | 返回請求按`asc`或`desc`順序排序. 默認為`desc` | ? | | `milestone` | string | no | 返回特定里程碑的合并請求. `None`返回沒有里程碑的合并請求. `Any`返回將合并具有指定里程碑的請求. | ? | | `view` | string | no | 如果為`simple` ,則返回`iid` ,URL,標題,描述和合并請求的基本狀態 | ? | | `labels` | string | no | 返回與逗號分隔的標簽列表匹配的合并請求. `None`列出所有沒有標簽的合并請求. `Any`列出所有具有至少一個標簽的合并請求. `No+Label` (不推薦使用)列出所有沒有標簽的合并請求. 預定義名稱不區分大小寫. | ? | | `with_labels_details` | boolean | no | If `true`, response will return more details for each label in labels field: `:name`, `:color`, `:description`, `:description_html`, `:text_color`. Default is `false`. Introduced in [GitLab 12.7](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/21413) | ? | | `with_merge_status_recheck` | boolean | no | 如果為`true` ,則此投影請求(但不保證)異步地重新計算`merge_status`字段. 默認值為`false` . 在[GitLab 13.0 中](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/31890)引入 | ? | | `created_after` | datetime | no | 返回在給定時間或之后創建的合并請求 | ? | | `created_before` | datetime | no | 返回在給定時間或之前創建的合并請求 | ? | | `updated_after` | datetime | no | 返回在給定時間或之后更新的合并請求 | ? | | `updated_before` | datetime | no | 返回在給定時間或之前更新的合并請求 | ? | | `scope` | string | no | 對于給定的范圍內返回的合并請求: `created_by_me` , `assigned_to_me`或`all` . 默認為`created_by_me` 對于 11.0 之前的版本,請改用現在不建議使用`created-by-me`范圍或`created-by-me` `assigned-to-me`范圍. | ? | | `author_id` | integer | no | 返回由給定用戶`id`創建的合并請求. 與`author_username` . 與`scope=all`或`scope=assigned_to_me` | ? | | `author_username` | string | no | 返回由給定`username`創建的合并請求. 與`author_id` . *(在 GitLab 12.10 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13060) )* | ? | | `assignee_id` | integer | no | 返回分配給給定用戶`id`合并請求. `None`將返回未分配的合并請求. `Any`退貨將請求與受讓人合并. | ? | | `approver_ids` | 整數數組 | no | 返回將所有具有給定`id`的用戶指定為單獨批準者的合并請求. `None`返回沒有批準者的合并請求. `Any`退貨將合并請求與批準人. | ? | | `approved_by_ids` | 整數數組 | no | 返回已被所有具有給定`id`的用戶(最大:5)批準的合并請求. `None`返回沒有批準的合并請求. `Any`退貨將請求與批準合并. | ? | | `my_reaction_emoji` | string | no | 返回合并請求,該合并請求由已驗證的用戶通過給定的`emoji`響應. `None`返回沒有響應的問題. 至少有一個反應, `Any`回報問題. *(在 GitLab 10.0 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/14016) )* | ? | | `source_branch` | string | no | 返回具有給定源分支的合并請求 | ? | | `target_branch` | string | no | 返回具有給定目標分支的合并請求 | ? | | `search` | string | no | 根據`title`和`description`搜索合并請求 | ? | | `in` | string | no | 修改`search`屬性的范圍. `title` , `description`或以逗號將它們連接在一起的字符串. 默認為`title,description` | ? | | `wip` | string | no | 過濾合并請求對他們的`wip`狀態. `yes` , *僅*返回 WIP 合并請求, `no` ,返回*非* WIP 合并請求 | ? | | `not` | Hash | no | 返回與提供的參數不匹配的合并請求. 接受: `labels` , `milestone` , `author_id` , `author_username` , `assignee_id` , `assignee_username` , `my_reaction_emoji` | ? | **注意:** [從 GitLab 13.0 開始](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/31890) ,列出合并請求可能不會主動更新`merge_status`字段(這也會影響`has_conflicts`字段),因為這可能是一項昂貴的操作. 如果您對此端點的這些字段的值感興趣,請在查詢`with_merge_status_recheck`參數設置為`true` .**注意:** [從 GitLab 12.8 開始,](https://gitlab.com/gitlab-org/gitlab/-/issues/29984)當對此端點發出請求時,將異步檢查每個合并請求的可合并性( `merge_status` ). 輪詢此 API 端點以獲取更新狀態. 這會影響`has_conflicts`屬性,因為它取決于`merge_status` . 除非`merge_status`為`cannot_be_merged`否則它將返回`false` . ``` [ { "id": 1, "iid": 1, "project_id": 3, "title": "test1", "description": "fixed login page css paddings", "state": "merged", "merged_by": { "id": 87854, "name": "Douwe Maan", "username": "DouweM", "state": "active", "avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png", "web_url": "https://gitlab.com/DouweM" }, "merged_at": "2018-09-07T11:16:17.520Z", "closed_by": null, "closed_at": null, "created_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z", "target_branch": "master", "source_branch": "test1", "upvotes": 0, "downvotes": 0, "author": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignee": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignees": [{ "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }], "source_project_id": 2, "target_project_id": 3, "labels": [ "Community contribution", "Manage" ], "work_in_progress": false, "milestone": { "id": 5, "iid": 1, "project_id": 3, "title": "v2.0", "description": "Assumenda aut placeat expedita exercitationem labore sunt enim earum.", "state": "closed", "created_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z", "due_date": "2018-09-22", "start_date": "2018-08-08", "web_url": "https://gitlab.example.com/my-group/my-project/milestones/1" }, "merge_when_pipeline_succeeds": true, "merge_status": "can_be_merged", "sha": "8888888888888888888888888888888888888888", "merge_commit_sha": null, "squash_commit_sha": null, "user_notes_count": 1, "discussion_locked": null, "should_remove_source_branch": true, "force_remove_source_branch": false, "allow_collaboration": false, "allow_maintainer_to_push": false, "web_url": "http://gitlab.example.com/my-group/my-project/merge_requests/1", "references": { "short": "!1", "relative": "my-group/my-project!1", "full": "my-group/my-project!1" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "squash": false, "task_completion_status":{ "count":0, "completed_count":0 } } ] ``` 在 GitLab 用戶[入門,青銅或更高](https://about.gitlab.com/pricing/)還會看到`approvals_before_merge`參數: ``` [ { "id": 1, "title": "test1", "approvals_before_merge": null ... } ] ``` ## List project merge requests[](#list-project-merge-requests "Permalink") 獲取此項目的所有合并請求. `state`參數可用于僅獲取具有給定狀態( `opened` , `closed` , `locked`或`merged` )或全部( `all` )的合并請求. 分頁參數`page`和`per_page`可用于限制合并請求的列表. ``` GET /projects/:id/merge_requests GET /projects/:id/merge_requests?state=opened GET /projects/:id/merge_requests?state=all GET /projects/:id/merge_requests?iids[]=42&iids[]=43 GET /projects/:id/merge_requests?milestone=release GET /projects/:id/merge_requests?labels=bug,reproduced GET /projects/:id/merge_requests?my_reaction_emoji=star ``` `project_id`代表 MR 所在項目的 ID. `project_id`將始終等于`target_project_id` . 如果來自同一項目的合并請求,則`source_project_id` , `target_project_id`和`project_id`將相同. 對于來自派生的合并請求, `target_project_id`和`project_id`將相同,并且`source_project_id`將是派生項目的 ID. Parameters: | Attribute | Type | Required | Description | ? | | --- | --- | --- | --- | --- | | `id` | integer | yes | 項目 ID | ? | | `iids[]` | 整數數組 | no | 返回具有給定`iid`的請求 | ? | | `state` | string | no | 返回所有合并請求,或者僅返回已`opened` , `closed` , `locked`或`merged`請求 | ? | | `order_by` | string | no | 返回由`created_at`或`updated_at`字段排序的請求. 默認為`created_at` | ? | | `sort` | string | no | 返回請求按`asc`或`desc`順序排序. 默認為`desc` | ? | | `milestone` | string | no | 返回特定里程碑的合并請求. `None`返回沒有里程碑的合并請求. `Any`返回將合并具有指定里程碑的請求. | ? | | `view` | string | no | 如果為`simple` ,則返回`iid` ,URL,標題,描述和合并請求的基本狀態 | ? | | `labels` | string | no | 返回與逗號分隔的標簽列表匹配的合并請求. `None`列出所有沒有標簽的合并請求. `Any`列出所有具有至少一個標簽的合并請求. `No+Label` (不推薦使用)列出所有沒有標簽的合并請求. 預定義名稱不區分大小寫. | ? | | `with_labels_details` | boolean | no | 如果為`true` ,則響應將為標簽字段中的每個標簽返回更多詳細信息`:name` , `:color` , `:description` , `:description_html` , `:text_color` . 默認值為`false` . 在[GitLab 12.7 中](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/21413)引入 | ? | | `with_merge_status_recheck` | boolean | no | 如果為`true` ,則此投影請求(但不保證)異步地重新計算`merge_status`字段. 默認值為`false` . 在[GitLab 13.0 中](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/31890)引入 | ? | | `created_after` | datetime | no | 返回在給定時間或之后創建的合并請求 | ? | | `created_before` | datetime | no | 返回在給定時間或之前創建的合并請求 | ? | | `updated_after` | datetime | no | 返回在給定時間或之后更新的合并請求 | ? | | `updated_before` | datetime | no | 返回在給定時間或之前更新的合并請求 | ? | | `scope` | string | no | 對于給定的范圍內返回的合并請求: `created_by_me` , `assigned_to_me`或`all` . 對于 11.0 之前的版本,請改用現在不建議使用`created-by-me`范圍或`created-by-me` `assigned-to-me`范圍. *(在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13060) .在 GitLab 11.0 中[更改為 snake_case](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/18935) )* | ? | | `author_id` | integer | no | 返回由給定用戶`id`創建的合并請求. 與`author_username` . *(在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13060) )* | ? | | `author_username` | string | no | 返回由給定`username`創建的合并請求. 與`author_id` . *(在 GitLab 12.10 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13060) )* | ? | | `assignee_id` | integer | no | 返回分配給給定用戶`id`合并請求. `None`將返回未分配的合并請求. `Any`退貨將請求與受讓人合并. *(在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13060) )* | ? | | `approver_ids` | 整數數組 | no | 返回將所有具有給定`id`的用戶指定為單獨批準者的合并請求. `None`返回沒有批準者的合并請求. `Any`退貨將合并請求與批準人. | ? | | `approved_by_ids` | 整數數組 | no | 返回已被所有具有給定`id`的用戶(最大:5)批準的合并請求. `None`返回沒有批準的合并請求. `Any`退貨將請求與批準合并. | ? | | `my_reaction_emoji` | string | no | 返回合并請求,該合并請求由已驗證的用戶通過給定的`emoji`響應. `None`返回沒有響應的問題. 至少有一個反應, `Any`回報問題. *(在 GitLab 10.0 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/14016) )* | ? | | `source_branch` | string | no | 返回具有給定源分支的合并請求 | ? | | `target_branch` | string | no | 返回具有給定目標分支的合并請求 | ? | | `search` | string | no | 根據`title`和`description`搜索合并請求 | ? | | `wip` | string | no | 過濾合并請求對他們的`wip`狀態. `yes` , *僅*返回 WIP 合并請求, `no` ,返回*非* WIP 合并請求 | ? | ``` [ { "id": 1, "iid": 1, "project_id": 3, "title": "test1", "description": "fixed login page css paddings", "state": "merged", "merged_by": { "id": 87854, "name": "Douwe Maan", "username": "DouweM", "state": "active", "avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png", "web_url": "https://gitlab.com/DouweM" }, "merged_at": "2018-09-07T11:16:17.520Z", "closed_by": null, "closed_at": null, "created_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z", "target_branch": "master", "source_branch": "test1", "upvotes": 0, "downvotes": 0, "author": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignee": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignees": [{ "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }], "source_project_id": 2, "target_project_id": 3, "labels": [ "Community contribution", "Manage" ], "work_in_progress": false, "milestone": { "id": 5, "iid": 1, "project_id": 3, "title": "v2.0", "description": "Assumenda aut placeat expedita exercitationem labore sunt enim earum.", "state": "closed", "created_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z", "due_date": "2018-09-22", "start_date": "2018-08-08", "web_url": "https://gitlab.example.com/my-group/my-project/milestones/1" }, "merge_when_pipeline_succeeds": true, "merge_status": "can_be_merged", "sha": "8888888888888888888888888888888888888888", "merge_commit_sha": null, "squash_commit_sha": null, "user_notes_count": 1, "discussion_locked": null, "should_remove_source_branch": true, "force_remove_source_branch": false, "allow_collaboration": false, "allow_maintainer_to_push": false, "web_url": "http://gitlab.example.com/my-group/my-project/merge_requests/1", "references": { "short": "!1", "relative": "!1", "full": "my-group/my-project!1" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "squash": false, "task_completion_status":{ "count":0, "completed_count":0 }, "has_conflicts": false, "blocking_discussions_resolved": true } ] ``` 在 GitLab 用戶[入門,青銅或更高](https://about.gitlab.com/pricing/)還會看到`approvals_before_merge`參數: ``` [ { "id": 1, "title": "test1", "approvals_before_merge": null ... } ] ``` ## List group merge requests[](#list-group-merge-requests "Permalink") 獲取該組及其子組的所有合并請求. `state`參數可用于僅獲取具有給定狀態( `opened` , `closed` , `locked`或`merged` )或全部( `all` )的合并請求. 分頁參數`page`和`per_page`可用于限制合并請求的列表. ``` GET /groups/:id/merge_requests GET /groups/:id/merge_requests?state=opened GET /groups/:id/merge_requests?state=all GET /groups/:id/merge_requests?milestone=release GET /groups/:id/merge_requests?labels=bug,reproduced GET /groups/:id/merge_requests?my_reaction_emoji=star ``` `group_id`代表包含 MR 所在項目的組的 ID. Parameters: | Attribute | Type | Required | Description | ? | | --- | --- | --- | --- | --- | | `id` | integer | yes | 組的 ID | ? | | `state` | string | no | 返回所有合并請求,或者僅返回已`opened` , `closed` , `locked`或`merged`請求 | ? | | `order_by` | string | no | 返回由`created_at`或`updated_at`字段排序的合并請求. 默認為`created_at` | ? | | `sort` | string | no | 返回以`asc`或`desc`順序排序的合并請求. 默認為`desc` | ? | | `milestone` | string | no | 返回特定里程碑的合并請求. `None`返回沒有里程碑的合并請求. `Any`返回將合并具有指定里程碑的請求. | ? | | `view` | string | no | If `simple`, returns the `iid`, URL, title, description, and basic state of merge request | ? | | `labels` | string | no | 返回與逗號分隔的標簽列表匹配的合并請求. `None`列出所有沒有標簽的合并請求. `Any`列出所有具有至少一個標簽的合并請求. `No+Label` (不推薦使用)列出所有沒有標簽的合并請求. 預定義名稱不區分大小寫. | ? | | `with_labels_details` | boolean | no | 如果為`true` ,則響應將為標簽字段中的每個標簽返回更多詳細信息`:name` , `:color` , `:description` , `:description_html` , `:text_color` . 默認值為`false` . 在[GitLab 12.7 中](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/21413)引入 | ? | | `with_merge_status_recheck` | boolean | no | 如果為`true` ,則此投影請求(但不保證)異步地重新計算`merge_status`字段. 默認值為`false` . 在[GitLab 13.0 中](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/31890)引入 | ? | | `created_after` | datetime | no | 返回在給定時間或之后創建的合并請求 | ? | | `created_before` | datetime | no | 返回在給定時間或之前創建的合并請求 | ? | | `updated_after` | datetime | no | 返回在給定時間或之后更新的合并請求 | ? | | `updated_before` | datetime | no | 返回在給定時間或之前更新的合并請求 | ? | | `scope` | string | no | 對于給定的范圍內返回的合并請求: `created_by_me` , `assigned_to_me`或`all` . | ? | | `author_id` | integer | no | 返回由給定用戶`id`創建的合并請求. 與`author_username` . *(在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13060) )* | ? | | `author_username` | string | no | 返回由給定`username`創建的合并請求. 與`author_id` . *(在 GitLab 12.10 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13060) )* | ? | | `assignee_id` | integer | no | 返回分配給給定用戶`id`合并請求. `None`將返回未分配的合并請求. `Any`退貨將請求與受讓人合并. *(在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13060) )* | ? | | `approver_ids` | 整數數組 | no | 返回將所有具有給定`id`的用戶指定為單獨批準者的合并請求. `None`返回沒有批準者的合并請求. `Any`退貨將合并請求與批準人. | ? | | `approved_by_ids` | 整數數組 | no | 返回已被所有具有給定`id`的用戶(最大:5)批準的合并請求. `None`返回沒有批準的合并請求. `Any`退貨將請求與批準合并. | ? | | `my_reaction_emoji` | string | no | 返回合并請求,該合并請求由已驗證的用戶通過給定的`emoji`響應. `None`返回沒有響應的問題. 至少有一個反應, `Any`回報問題. *(在 GitLab 10.0 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/14016) )* | ? | | `source_branch` | string | no | 返回具有給定源分支的合并請求 | ? | | `target_branch` | string | no | 返回具有給定目標分支的合并請求 | ? | | `search` | string | no | 根據`title`和`description`搜索合并請求 | ? | | `non_archived` | boolean | no | 僅從非歸檔項目返回合并請求. 默認為 true. *(在[GitLab 12.8 中](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/23809)引入)* | ? | ``` [ { "id": 1, "iid": 1, "project_id": 3, "title": "test1", "description": "fixed login page css paddings", "state": "merged", "merged_by": { "id": 87854, "name": "Douwe Maan", "username": "DouweM", "state": "active", "avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png", "web_url": "https://gitlab.com/DouweM" }, "merged_at": "2018-09-07T11:16:17.520Z", "closed_by": null, "closed_at": null, "created_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z", "target_branch": "master", "source_branch": "test1", "upvotes": 0, "downvotes": 0, "author": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignee": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignees": [{ "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }], "source_project_id": 2, "target_project_id": 3, "labels": [ "Community contribution", "Manage" ], "work_in_progress": false, "milestone": { "id": 5, "iid": 1, "project_id": 3, "title": "v2.0", "description": "Assumenda aut placeat expedita exercitationem labore sunt enim earum.", "state": "closed", "created_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z", "due_date": "2018-10-22", "start_date": "2018-09-08", "web_url": "gitlab.example.com/my-group/my-project/milestones/1" }, "merge_when_pipeline_succeeds": true, "merge_status": "can_be_merged", "sha": "8888888888888888888888888888888888888888", "merge_commit_sha": null, "squash_commit_sha": null, "user_notes_count": 1, "discussion_locked": null, "should_remove_source_branch": true, "force_remove_source_branch": false, "web_url": "http://gitlab.example.com/my-group/my-project/merge_requests/1", "references": { "short": "!1", "relative": "my-project!1", "full": "my-group/my-project!1" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "squash": false, "task_completion_status":{ "count":0, "completed_count":0 }, "has_conflicts": false, "blocking_discussions_resolved": true } ] ``` 在 GitLab 用戶[入門,青銅或更高](https://about.gitlab.com/pricing/)還會看到`approvals_before_merge`參數: ``` [ { "id": 1, "title": "test1", "approvals_before_merge": null ... } ] ``` ## Get single MR[](#get-single-mr "Permalink") 顯示有關單個合并請求的信息. **注意** :響應中的`changes_count`值是一個字符串,而不是整數. 這是因為當 MR 有太多要顯示和存儲的更改時,其上限為 1,000\. 在這種情況下,API 將為更改計數返回字符串`"1000+"` . ``` GET /projects/:id/merge_requests/:merge_request_iid ``` Parameters: * `id` (必填)-經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) * `merge_request_iid` (必需)-合并請求的內部 ID * `render_html` (optional) - If `true` response includes rendered HTML for title and description * `include_diverged_commits_count` (可選)-如果為`true`包括目標分支后面的提交 * `include_rebase_in_progress` (可選)-如果為`true`包括是否正在進行 rebase 操作 **注意:** [從 GitLab 12.8 開始,](https://gitlab.com/gitlab-org/gitlab/-/issues/29984)當對此端點發出請求時,將異步檢查合并請求的可合并性( `merge_status` ). 輪詢此 API 端點以獲取更新狀態. 這會影響`has_conflicts`屬性,因為它取決于`merge_status` . 除非`merge_status`為`cannot_be_merged`否則它將返回`false` . ``` { "id": 1, "iid": 1, "project_id": 3, "title": "test1", "description": "fixed login page css paddings", "state": "merged", "created_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z", "target_branch": "master", "source_branch": "test1", "upvotes": 0, "downvotes": 0, "author": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "user" : { "can_merge" : false }, "assignee": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignees": [{ "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }], "source_project_id": 2, "target_project_id": 3, "labels": [ "Community contribution", "Manage" ], "work_in_progress": false, "milestone": { "id": 5, "iid": 1, "project_id": 3, "title": "v2.0", "description": "Assumenda aut placeat expedita exercitationem labore sunt enim earum.", "state": "closed", "created_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z", "due_date": "2018-09-22", "start_date": "2018-08-08", "web_url": "https://gitlab.example.com/my-group/my-project/milestones/1" }, "merge_when_pipeline_succeeds": true, "merge_status": "can_be_merged", "merge_error": null, "sha": "8888888888888888888888888888888888888888", "merge_commit_sha": null, "squash_commit_sha": null, "user_notes_count": 1, "discussion_locked": null, "should_remove_source_branch": true, "force_remove_source_branch": false, "allow_collaboration": false, "allow_maintainer_to_push": false, "web_url": "http://gitlab.example.com/my-group/my-project/merge_requests/1", "references": { "short": "!1", "relative": "!1", "full": "my-group/my-project!1" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "squash": false, "subscribed": false, "changes_count": "1", "merged_by": { "id": 87854, "name": "Douwe Maan", "username": "DouweM", "state": "active", "avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png", "web_url": "https://gitlab.com/DouweM" }, "merged_at": "2018-09-07T11:16:17.520Z", "closed_by": null, "closed_at": null, "latest_build_started_at": "2018-09-07T07:27:38.472Z", "latest_build_finished_at": "2018-09-07T08:07:06.012Z", "first_deployed_to_production_at": null, "pipeline": { "id": 29626725, "sha": "2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f", "ref": "patch-28", "status": "success", "web_url": "https://gitlab.example.com/my-group/my-project/pipelines/29626725" }, "diff_refs": { "base_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00", "head_sha": "2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f", "start_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00" }, "diverged_commits_count": 2, "rebase_in_progress": false, "first_contribution": false, "task_completion_status":{ "count":0, "completed_count":0 }, "has_conflicts": false, "blocking_discussions_resolved": true } ``` 在 GitLab 用戶[入門,青銅或更高](https://about.gitlab.com/pricing/)還會看到`approvals_before_merge`參數: ``` { "id": 1, "title": "test1", "approvals_before_merge": null ... } ``` ## Get single MR participants[](#get-single-mr-participants "Permalink") 獲取合并請求參與者的列表. ``` GET /projects/:id/merge_requests/:merge_request_iid/participants ``` Parameters: * `id` (必填)-經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) * `merge_request_iid` (必需)-合并請求的內部 ID ``` [ { "id": 1, "name": "John Doe1", "username": "user1", "state": "active", "avatar_url": "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon", "web_url": "http://localhost/user1" }, { "id": 2, "name": "John Doe2", "username": "user2", "state": "active", "avatar_url": "http://www.gravatar.com/avatar/10fc7f102be8de7657fb4d80898bbfe3?s=80&d=identicon", "web_url": "http://localhost/user2" } ] ``` ## Get single MR commits[](#get-single-mr-commits "Permalink") 獲取合并請求提交的列表. ``` GET /projects/:id/merge_requests/:merge_request_iid/commits ``` Parameters: * `id` (必填)-經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) * `merge_request_iid` (必需)-合并請求的內部 ID ``` [ { "id": "ed899a2f4b50b4370feeea94676502b42383c746", "short_id": "ed899a2f4b5", "title": "Replace sanitize with escape once", "author_name": "Example User", "author_email": "user@example.com", "created_at": "2012-09-20T11:50:22+03:00", "message": "Replace sanitize with escape once" }, { "id": "6104942438c14ec7bd21c6cd5bd995272b3faff6", "short_id": "6104942438c", "title": "Sanitize for network graph", "author_name": "Example User", "author_email": "user@example.com", "created_at": "2012-09-20T09:06:12+03:00", "message": "Sanitize for network graph" } ] ``` ## Get single MR changes[](#get-single-mr-changes "Permalink") 顯示有關合并請求的信息,包括其文件和更改. ``` GET /projects/:id/merge_requests/:merge_request_iid/changes ``` Parameters: * `id` (必填)-經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) * `merge_request_iid` (必需)-合并請求的內部 ID ``` { "id": 21, "iid": 1, "project_id": 4, "title": "Blanditiis beatae suscipit hic assumenda et molestias nisi asperiores repellat et.", "state": "reopened", "created_at": "2015-02-02T19:49:39.159Z", "updated_at": "2015-02-02T20:08:49.959Z", "target_branch": "secret_token", "source_branch": "version-1-9", "upvotes": 0, "downvotes": 0, "author": { "name": "Chad Hamill", "username": "jarrett", "id": 5, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/b95567800f828948baf5f4160ebb2473?s=40&d=identicon", "web_url" : "https://gitlab.example.com/jarrett" }, "assignee": { "name": "Administrator", "username": "root", "id": 1, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40&d=identicon", "web_url" : "https://gitlab.example.com/root" }, "assignees": [{ "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }], "source_project_id": 4, "target_project_id": 4, "labels": [ ], "description": "Qui voluptatibus placeat ipsa alias quasi. Deleniti rem ut sint. Optio velit qui distinctio.", "work_in_progress": false, "milestone": { "id": 5, "iid": 1, "project_id": 4, "title": "v2.0", "description": "Assumenda aut placeat expedita exercitationem labore sunt enim earum.", "state": "closed", "created_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z", "due_date": null }, "merge_when_pipeline_succeeds": true, "merge_status": "can_be_merged", "subscribed" : true, "sha": "8888888888888888888888888888888888888888", "merge_commit_sha": null, "squash_commit_sha": null, "user_notes_count": 1, "changes_count": "1", "should_remove_source_branch": true, "force_remove_source_branch": false, "squash": false, "web_url": "http://gitlab.example.com/my-group/my-project/merge_requests/1", "references": { "short": "!1", "relative": "!1", "full": "my-group/my-project!1" }, "discussion_locked": false, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "task_completion_status":{ "count":0, "completed_count":0 }, "changes": [ { "old_path": "VERSION", "new_path": "VERSION", "a_mode": "100644", "b_mode": "100644", "diff": "--- a/VERSION\ +++ b/VERSION\ @@ -1 +1 @@\ -1.9.7\ +1.9.8", "new_file": false, "renamed_file": false, "deleted_file": false } ] } ``` ## List MR pipelines[](#list-mr-pipelines "Permalink") 在 GitLab 10.5.0 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/15454) . 獲取合并請求管道的列表. ``` GET /projects/:id/merge_requests/:merge_request_iid/pipelines ``` Parameters: * `id` (必填)-經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) * `merge_request_iid` (必需)-合并請求的內部 ID ``` [ { "id": 77, "sha": "959e04d7c7a30600c894bd3c0cd0e1ce7f42c11d", "ref": "master", "status": "success" } ] ``` ## Create MR Pipeline[](#create-mr-pipeline "Permalink") 在 GitLab 12.3 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/31722) . [為合并請求](../ci/merge_request_pipelines/index.html)創建一個新[管道](../ci/merge_request_pipelines/index.html) . 通過這個端點創建的管道將無法運行常規的分支/標簽的管道,它需要`.gitlab-ci.yml`與配置`only: [merge_requests]`創造就業機會. 新管道可以是: * 分離的合并請求管道. * A [pipeline for merged results](../ci/merge_request_pipelines/pipelines_for_merged_results/index.html) if the [project setting is enabled](../ci/merge_request_pipelines/pipelines_for_merged_results/index.html#enable-pipelines-for-merged-results). ``` POST /projects/:id/merge_requests/:merge_request_iid/pipelines ``` Parameters: * `id` (必填)-項目的 ID 或[URL 編碼的路徑](README.html#namespaced-path-encoding) * `merge_request_iid` (必需)-合并請求的內部 ID ``` { "id": 2, "sha": "b83d6e391c22777fca1ed3012fce84f633d7fed0", "ref": "refs/merge-requests/1/head", "status": "pending", "web_url": "http://localhost/user1/project1/pipelines/2", "before_sha": "0000000000000000000000000000000000000000", "tag": false, "yaml_errors": null, "user": { "id": 1, "name": "John Doe1", "username": "user1", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon", "web_url": "http://example.com" }, "created_at": "2019-09-04T19:20:18.267Z", "updated_at": "2019-09-04T19:20:18.459Z", "started_at": null, "finished_at": null, "committed_at": null, "duration": null, "coverage": null, "detailed_status": { "icon": "status_pending", "text": "pending", "label": "pending", "group": "pending", "tooltip": "pending", "has_details": false, "details_path": "/user1/project1/pipelines/2", "illustration": null, "favicon": "/assets/ci_favicons/favicon_status_pending-5bdf338420e5221ca24353b6bff1c9367189588750632e9a871b7af09ff6a2ae.png" } } ``` ## Create MR[](#create-mr "Permalink") 創建一個新的合并請求. ``` POST /projects/:id/merge_requests ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) | | `source_branch` | string | yes | 源分支 | | `target_branch` | string | yes | 目標分支 | | `title` | string | yes | 先生的頭銜 | | `assignee_id` | integer | no | 受讓人用戶 ID | | `assignee_ids` | 整數數組 | no | 要將 MR 分配給的用戶的 ID. 設置為`0`或提供一個空值以取消分配所有受讓人. | | `description` | string | no | MR 的描述. 限制為 1,048,576 個字符. | | `target_project_id` | integer | no | 目標項目(數字 ID) | | `labels` | string | no | MR 的標簽以逗號分隔的列表 | | `milestone_id` | integer | no | 里程碑的全局 ID | | `remove_source_branch` | boolean | no | 指示合并請求是否應在合并時刪除源分支的標志 | | `allow_collaboration` | boolean | no | 允許來自可以合并到目標分支的成員的提交 | | `allow_maintainer_to_push` | boolean | no | Deprecated, see allow_collaboration | | `squash` | boolean | no | 合并時將 Squash 提交到單個提交中 | 如果`approvals_before_merge` 未提供,它將從目標項目繼承值. 如果提供了它,則必須滿足以下條件才能使其生效: 1. 目標項目的`approvals_before_merge`必須大于零. 零值將禁用該項目的批準. 2. 所提供的價值`approvals_before_merge`必須比目標項目的更大`approvals_before_merge` . ``` { "id": 1, "iid": 1, "project_id": 3, "title": "test1", "description": "fixed login page css paddings", "state": "merged", "created_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z", "target_branch": "master", "source_branch": "test1", "upvotes": 0, "downvotes": 0, "author": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignee": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "source_project_id": 2, "target_project_id": 3, "labels": [ "Community contribution", "Manage" ], "work_in_progress": false, "milestone": { "id": 5, "iid": 1, "project_id": 3, "title": "v2.0", "description": "Assumenda aut placeat expedita exercitationem labore sunt enim earum.", "state": "closed", "created_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z", "due_date": "2018-09-22", "start_date": "2018-08-08", "web_url": "https://gitlab.example.com/my-group/my-project/milestones/1" }, "merge_when_pipeline_succeeds": true, "merge_status": "can_be_merged", "merge_error": null, "sha": "8888888888888888888888888888888888888888", "merge_commit_sha": null, "squash_commit_sha": null, "user_notes_count": 1, "discussion_locked": null, "should_remove_source_branch": true, "force_remove_source_branch": false, "allow_collaboration": false, "allow_maintainer_to_push": false, "web_url": "http://gitlab.example.com/my-group/my-project/merge_requests/1", "references": { "short": "!1", "relative": "!1", "full": "my-group/my-project!1" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "squash": false, "subscribed": false, "changes_count": "1", "merged_by": { "id": 87854, "name": "Douwe Maan", "username": "DouweM", "state": "active", "avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png", "web_url": "https://gitlab.com/DouweM" }, "merged_at": "2018-09-07T11:16:17.520Z", "closed_by": null, "closed_at": null, "latest_build_started_at": "2018-09-07T07:27:38.472Z", "latest_build_finished_at": "2018-09-07T08:07:06.012Z", "first_deployed_to_production_at": null, "pipeline": { "id": 29626725, "sha": "2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f", "ref": "patch-28", "status": "success", "web_url": "https://gitlab.example.com/my-group/my-project/pipelines/29626725" }, "diff_refs": { "base_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00", "head_sha": "2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f", "start_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00" }, "diverged_commits_count": 2, "task_completion_status":{ "count":0, "completed_count":0 } } ``` 在 GitLab 用戶[入門,青銅或更高](https://about.gitlab.com/pricing/)還會看到`approvals_before_merge`參數: ``` { "id": 1, "title": "test1", "approvals_before_merge": null ... } ``` ## Update MR[](#update-mr "Permalink") 更新現有的合并請求. 您可以更改目標分支,標題,甚至關閉 MR. ``` PUT /projects/:id/merge_requests/:merge_request_iid ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) | | `merge_request_iid` | integer | yes | 合并請求的 ID | | `target_branch` | string | no | 目標分支 | | `title` | string | no | 先生的頭銜 | | `assignee_id` | integer | no | 要將合并請求分配給的用戶的 ID. 設置為`0`或提供一個空值以取消分配所有受讓人. | | `assignee_ids` | 整數數組 | no | 要將 MR 分配給的用戶的 ID. 設置為`0`或提供一個空值以取消分配所有受讓人. | | `milestone_id` | integer | no | 要將合并請求分配給的里程碑的全局 ID. 設置為`0`或提供一個空值以取消分配里程碑. | | `labels` | string | no | 合并請求的逗號分隔標簽名稱. 設置為空字符串以取消分配所有標簽. | | `add_labels` | string | no | 以逗號分隔的標簽名稱,添加到合并請求中. | | `remove_labels` | string | no | 逗號分隔的標簽名稱,可從合并請求中刪除. | | `description` | string | no | MR 的描述. 限制為 1,048,576 個字符. | | `state_event` | string | no | 新狀態(關閉/重新打開) | | `remove_source_branch` | boolean | no | 指示合并請求是否應在合并時刪除源分支的標志 | | `squash` | boolean | no | 合并時將 Squash 提交到單個提交中 | | `discussion_locked` | boolean | no | 指示合并請求的討論是否已鎖定的標志. 如果討論被鎖定,則只有項目成員可以添加,編輯或解決評論. | | `allow_collaboration` | boolean | no | 允許來自可以合并到目標分支的成員的提交 | | `allow_maintainer_to_push` | boolean | no | 已棄用,請參見 allow_collaboration | 必須至少包含一個以上非必需的屬性. ``` { "id": 1, "iid": 1, "project_id": 3, "title": "test1", "description": "fixed login page css paddings", "state": "merged", "created_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z", "target_branch": "master", "source_branch": "test1", "upvotes": 0, "downvotes": 0, "author": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignee": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignees": [{ "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }], "source_project_id": 2, "target_project_id": 3, "labels": [ "Community contribution", "Manage" ], "work_in_progress": false, "milestone": { "id": 5, "iid": 1, "project_id": 3, "title": "v2.0", "description": "Assumenda aut placeat expedita exercitationem labore sunt enim earum.", "state": "closed", "created_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z", "due_date": "2018-09-22", "start_date": "2018-08-08", "web_url": "https://gitlab.example.com/my-group/my-project/milestones/1" }, "merge_when_pipeline_succeeds": true, "merge_status": "can_be_merged", "merge_error": null, "sha": "8888888888888888888888888888888888888888", "merge_commit_sha": null, "squash_commit_sha": null, "user_notes_count": 1, "discussion_locked": null, "should_remove_source_branch": true, "force_remove_source_branch": false, "allow_collaboration": false, "allow_maintainer_to_push": false, "web_url": "http://gitlab.example.com/my-group/my-project/merge_requests/1", "references": { "short": "!1", "relative": "!1", "full": "my-group/my-project!1" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "squash": false, "subscribed": false, "changes_count": "1", "merged_by": { "id": 87854, "name": "Douwe Maan", "username": "DouweM", "state": "active", "avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png", "web_url": "https://gitlab.com/DouweM" }, "merged_at": "2018-09-07T11:16:17.520Z", "closed_by": null, "closed_at": null, "latest_build_started_at": "2018-09-07T07:27:38.472Z", "latest_build_finished_at": "2018-09-07T08:07:06.012Z", "first_deployed_to_production_at": null, "pipeline": { "id": 29626725, "sha": "2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f", "ref": "patch-28", "status": "success", "web_url": "https://gitlab.example.com/my-group/my-project/pipelines/29626725" }, "diff_refs": { "base_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00", "head_sha": "2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f", "start_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00" }, "diverged_commits_count": 2, "task_completion_status":{ "count":0, "completed_count":0 } } ``` 在 GitLab 用戶[入門,青銅或更高](https://about.gitlab.com/pricing/)還會看到`approvals_before_merge`參數: ``` { "id": 1, "title": "test1", "approvals_before_merge": null ... } ``` ## Delete a merge request[](#delete-a-merge-request "Permalink") 僅適用于管理員和項目所有者. 刪除相關合并請求. ``` DELETE /projects/:id/merge_requests/:merge_request_iid ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) | | `merge_request_iid` | integer | yes | 合并請求的內部 ID | ``` curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/4/merge_requests/85" ``` ## Accept MR[](#accept-mr "Permalink") 使用此 API 合并通過 MR 提交的更改. 如果合并請求無法被接受(例如:進行中,已關閉,正在等待管道完成或在要求成功時失敗)-您將收到`405`和錯誤消息"不允許使用方法" 如果存在一些沖突且無法合并-您將收到`406` ,并且錯誤消息"分支無法合并" 如果傳遞了`sha`參數,但與源頭的 HEAD 不匹配-您將得到`409`且錯誤消息" SHA 與源分支的 HEAD 不匹配" 如果您沒有接受此合并請求的權限-您會收到`401` ``` PUT /projects/:id/merge_requests/:merge_request_iid/merge ``` Parameters: * `id` (必填)-經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) * `merge_request_iid` (必需) `merge_request_iid`內部 ID * `merge_commit_message` (optional) - Custom merge commit message * `squash_commit_message` (可選)-自定義南瓜提交消息 * `squash` (可選)-如果為`true`則提交將在合并時被壓縮為單個提交 * `should_remove_source_branch` (可選)-如果為`true`刪除源分支 * `merge_when_pipeline_succeeds` (可選)-如果為`true` ,則在管道成功時合并 MR * `sha` (可選)-如果存在,則此 SHA 必須與源分支的 HEAD 匹配,否則合并將失敗 ``` { "id": 1, "iid": 1, "project_id": 3, "title": "test1", "description": "fixed login page css paddings", "state": "merged", "created_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z", "target_branch": "master", "source_branch": "test1", "upvotes": 0, "downvotes": 0, "author": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignee": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignees": [{ "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }], "source_project_id": 2, "target_project_id": 3, "labels": [ "Community contribution", "Manage" ], "work_in_progress": false, "milestone": { "id": 5, "iid": 1, "project_id": 3, "title": "v2.0", "description": "Assumenda aut placeat expedita exercitationem labore sunt enim earum.", "state": "closed", "created_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z", "due_date": "2018-09-22", "start_date": "2018-08-08", "web_url": "https://gitlab.example.com/my-group/my-project/milestones/1" }, "merge_when_pipeline_succeeds": true, "merge_status": "can_be_merged", "merge_error": null, "sha": "8888888888888888888888888888888888888888", "merge_commit_sha": null, "squash_commit_sha": null, "user_notes_count": 1, "discussion_locked": null, "should_remove_source_branch": true, "force_remove_source_branch": false, "allow_collaboration": false, "allow_maintainer_to_push": false, "web_url": "http://gitlab.example.com/my-group/my-project/merge_requests/1", "references": { "short": "!1", "relative": "!1", "full": "my-group/my-project!1" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "squash": false, "subscribed": false, "changes_count": "1", "merged_by": { "id": 87854, "name": "Douwe Maan", "username": "DouweM", "state": "active", "avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png", "web_url": "https://gitlab.com/DouweM" }, "merged_at": "2018-09-07T11:16:17.520Z", "closed_by": null, "closed_at": null, "latest_build_started_at": "2018-09-07T07:27:38.472Z", "latest_build_finished_at": "2018-09-07T08:07:06.012Z", "first_deployed_to_production_at": null, "pipeline": { "id": 29626725, "sha": "2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f", "ref": "patch-28", "status": "success", "web_url": "https://gitlab.example.com/my-group/my-project/pipelines/29626725" }, "diff_refs": { "base_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00", "head_sha": "2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f", "start_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00" }, "diverged_commits_count": 2, "task_completion_status":{ "count":0, "completed_count":0 } } ``` 在 GitLab 用戶[入門,青銅或更高](https://about.gitlab.com/pricing/)還會看到`approvals_before_merge`參數: ``` { "id": 1, "title": "test1", "approvals_before_merge": null ... } ``` ## Merge to default merge ref path[](#merge-to-default-merge-ref-path "Permalink") 如果可能,將合并請求源和目標分支之間的更改合并到目標項目存儲庫的`refs/merge-requests/:iid/merge` ref 中. 如果執行常規合并操作,此引用將具有目標分支將具有的狀態. 這不是常規的合并操作,因為它不會以任何方式更改合并請求目標分支的狀態. 向此 API 提交請求時,此 ref( `refs/merge-requests/:iid/merge` )不一定會被覆蓋,盡管它可以確保 ref 具有最新的狀態. 如果合并請求有沖突,為空或已經合并,您將收到一條`400`和一個描述性錯誤消息. 如果為`200`它將在響應正文中返回`refs/merge-requests/:iid/merge`的 HEAD 提交. ``` GET /projects/:id/merge_requests/:merge_request_iid/merge_ref ``` Parameters: * `id` (必填)-經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) * `merge_request_iid` (必需) `merge_request_iid`內部 ID ``` { "commit_id": "854a3a7a17acbcc0bbbea170986df1eb60435f34" } ``` ## Cancel Merge When Pipeline Succeeds[](#cancel-merge-when-pipeline-succeeds "Permalink") 如果您沒有接受此合并請求的權限-您會收到`401` 如果合并請求已被合并或關閉-您將收到`405`和錯誤消息"不允許使用方法" 如果在管道成功時未將合并請求設置為要合并,則還會收到`406`錯誤. ``` POST /projects/:id/merge_requests/:merge_request_iid/cancel_merge_when_pipeline_succeeds ``` Parameters: * `id` (必填)-經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) * `merge_request_iid` (必需) `merge_request_iid`內部 ID ``` { "id": 1, "iid": 1, "project_id": 3, "title": "test1", "description": "fixed login page css paddings", "state": "merged", "created_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z", "target_branch": "master", "source_branch": "test1", "upvotes": 0, "downvotes": 0, "author": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignee": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignees": [{ "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }], "source_project_id": 2, "target_project_id": 3, "labels": [ "Community contribution", "Manage" ], "work_in_progress": false, "milestone": { "id": 5, "iid": 1, "project_id": 3, "title": "v2.0", "description": "Assumenda aut placeat expedita exercitationem labore sunt enim earum.", "state": "closed", "created_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z", "due_date": "2018-09-22", "start_date": "2018-08-08", "web_url": "https://gitlab.example.com/my-group/my-project/milestones/1" }, "merge_when_pipeline_succeeds": false, "merge_status": "can_be_merged", "merge_error": null, "sha": "8888888888888888888888888888888888888888", "merge_commit_sha": null, "squash_commit_sha": null, "user_notes_count": 1, "discussion_locked": null, "should_remove_source_branch": true, "force_remove_source_branch": false, "allow_collaboration": false, "allow_maintainer_to_push": false, "web_url": "http://gitlab.example.com/my-group/my-project/merge_requests/1", "references": { "short": "!1", "relative": "!1", "full": "my-group/my-project!1" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "squash": false, "subscribed": false, "changes_count": "1", "merged_by": { "id": 87854, "name": "Douwe Maan", "username": "DouweM", "state": "active", "avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png", "web_url": "https://gitlab.com/DouweM" }, "merged_at": "2018-09-07T11:16:17.520Z", "closed_by": null, "closed_at": null, "latest_build_started_at": "2018-09-07T07:27:38.472Z", "latest_build_finished_at": "2018-09-07T08:07:06.012Z", "first_deployed_to_production_at": null, "pipeline": { "id": 29626725, "sha": "2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f", "ref": "patch-28", "status": "success", "web_url": "https://gitlab.example.com/my-group/my-project/pipelines/29626725" }, "diff_refs": { "base_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00", "head_sha": "2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f", "start_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00" }, "diverged_commits_count": 2, "task_completion_status":{ "count":0, "completed_count":0 } } ``` 在 GitLab 用戶[入門,青銅或更高](https://about.gitlab.com/pricing/)還會看到`approvals_before_merge`參數: ``` { "id": 1, "title": "test1", "approvals_before_merge": null ... } ``` ## Rebase a merge request[](#rebase-a-merge-request "Permalink") 自動將合并請求的`source_branch`與其`target_branch` . 如果您無權推送到合并請求的源分支-您將收到`403 Forbidden`響應. ``` PUT /projects/:id/merge_requests/:merge_request_iid/rebase ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) | | `merge_request_iid` | integer | yes | 合并請求的內部 ID | | `skip_ci` | boolean | no | 設置為`true`以跳過創建 CI 管道 | ``` curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/76/merge_requests/1/rebase" ``` 這是一個異步請求. 如果請求成功入隊,API 將返回`202 Accepted`響應,響應包含: ``` { "rebase_in_progress": true } ``` 您可以使用`include_rebase_in_progress`參數輪詢" [獲取單個 MR"](#get-single-mr)端點,以檢查異步請求的狀態. 如果正在進行 rebase 操作,則響應將包括以下內容: ``` { "rebase_in_progress": true, "merge_error": null } ``` 一旦成功完成了變基操作,響應將包括以下內容: ``` { "rebase_in_progress": false, "merge_error": null } ``` 如果 rebase 操作失敗,響應將包括以下內容: ``` { "rebase_in_progress": false, "merge_error": "Rebase failed. Please rebase locally" } ``` ## Comments on merge requests[](#comments-on-merge-requests "Permalink") 注釋是通過[notes](notes.html)資源完成的. ## List issues that will close on merge[](#list-issues-that-will-close-on-merge "Permalink") 通過合并提供的合并請求來獲取所有將要解決的問題. ``` GET /projects/:id/merge_requests/:merge_request_iid/closes_issues ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) | | `merge_request_iid` | integer | yes | 合并請求的內部 ID | ``` curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/76/merge_requests/1/closes_issues" ``` 使用 GitLab 問題跟蹤器時的示例響應: ``` [ { "state" : "opened", "description" : "Ratione dolores corrupti mollitia soluta quia.", "author" : { "state" : "active", "id" : 18, "web_url" : "https://gitlab.example.com/eileen.lowe", "name" : "Alexandra Bashirian", "avatar_url" : null, "username" : "eileen.lowe" }, "milestone" : { "project_id" : 1, "description" : "Ducimus nam enim ex consequatur cumque ratione.", "state" : "closed", "due_date" : null, "iid" : 2, "created_at" : "2016-01-04T15:31:39.996Z", "title" : "v4.0", "id" : 17, "updated_at" : "2016-01-04T15:31:39.996Z" }, "project_id" : 1, "assignee" : { "state" : "active", "id" : 1, "name" : "Administrator", "web_url" : "https://gitlab.example.com/root", "avatar_url" : null, "username" : "root" }, "updated_at" : "2016-01-04T15:31:51.081Z", "id" : 76, "title" : "Consequatur vero maxime deserunt laboriosam est voluptas dolorem.", "created_at" : "2016-01-04T15:31:51.081Z", "iid" : 6, "labels" : [], "user_notes_count": 1, "changes_count": "1" } ] ``` 使用外部問題跟蹤器(例如 Jira)時的示例響應: ``` [ { "id" : "PROJECT-123", "title" : "Title of this issue" } ] ``` ## Subscribe to a merge request[](#subscribe-to-a-merge-request "Permalink") 向已認證的用戶訂閱合并請求以接收通知. 如果用戶已經訂閱了合并請求,則返回狀態碼`304` . ``` POST /projects/:id/merge_requests/:merge_request_iid/subscribe ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) | | `merge_request_iid` | integer | yes | 合并請求的內部 ID | ``` curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/17/subscribe" ``` 響應示例: ``` { "id": 1, "iid": 1, "project_id": 3, "title": "test1", "description": "fixed login page css paddings", "state": "merged", "created_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z", "target_branch": "master", "source_branch": "test1", "upvotes": 0, "downvotes": 0, "author": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignee": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignees": [{ "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }], "source_project_id": 2, "target_project_id": 3, "labels": [ "Community contribution", "Manage" ], "work_in_progress": false, "milestone": { "id": 5, "iid": 1, "project_id": 3, "title": "v2.0", "description": "Assumenda aut placeat expedita exercitationem labore sunt enim earum.", "state": "closed", "created_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z", "due_date": "2018-09-22", "start_date": "2018-08-08", "web_url": "https://gitlab.example.com/my-group/my-project/milestones/1" }, "merge_when_pipeline_succeeds": true, "merge_status": "can_be_merged", "sha": "8888888888888888888888888888888888888888", "merge_commit_sha": null, "squash_commit_sha": null, "user_notes_count": 1, "discussion_locked": null, "should_remove_source_branch": true, "force_remove_source_branch": false, "allow_collaboration": false, "allow_maintainer_to_push": false, "web_url": "http://gitlab.example.com/my-group/my-project/merge_requests/1", "references": { "short": "!1", "relative": "!1", "full": "my-group/my-project!1" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "squash": false, "subscribed": false, "changes_count": "1", "merged_by": { "id": 87854, "name": "Douwe Maan", "username": "DouweM", "state": "active", "avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png", "web_url": "https://gitlab.com/DouweM" }, "merged_at": "2018-09-07T11:16:17.520Z", "closed_by": null, "closed_at": null, "latest_build_started_at": "2018-09-07T07:27:38.472Z", "latest_build_finished_at": "2018-09-07T08:07:06.012Z", "first_deployed_to_production_at": null, "pipeline": { "id": 29626725, "sha": "2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f", "ref": "patch-28", "status": "success", "web_url": "https://gitlab.example.com/my-group/my-project/pipelines/29626725" }, "diff_refs": { "base_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00", "head_sha": "2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f", "start_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00" }, "diverged_commits_count": 2, "task_completion_status":{ "count":0, "completed_count":0 } } ``` 在 GitLab 用戶[入門,青銅或更高](https://about.gitlab.com/pricing/)還會看到`approvals_before_merge`參數: ``` { "id": 1, "title": "test1", "approvals_before_merge": null ... } ``` ## Unsubscribe from a merge request[](#unsubscribe-from-a-merge-request "Permalink") 從合并請求中退訂已認證的用戶,以不接收來自該合并請求的通知. 如果用戶未訂閱合并請求,則返回狀態碼`304` . ``` POST /projects/:id/merge_requests/:merge_request_iid/unsubscribe ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) | | `merge_request_iid` | integer | yes | 合并請求的內部 ID | ``` curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/17/unsubscribe" ``` 響應示例: ``` { "id": 1, "iid": 1, "project_id": 3, "title": "test1", "description": "fixed login page css paddings", "state": "merged", "created_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z", "target_branch": "master", "source_branch": "test1", "upvotes": 0, "downvotes": 0, "author": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignee": { "id": 1, "name": "Administrator", "username": "admin", "state": "active", "avatar_url": null, "web_url" : "https://gitlab.example.com/admin" }, "assignees": [{ "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }], "source_project_id": 2, "target_project_id": 3, "labels": [ "Community contribution", "Manage" ], "work_in_progress": false, "milestone": { "id": 5, "iid": 1, "project_id": 3, "title": "v2.0", "description": "Assumenda aut placeat expedita exercitationem labore sunt enim earum.", "state": "closed", "created_at": "2015-02-02T19:49:26.013Z", "updated_at": "2015-02-02T19:49:26.013Z", "due_date": "2018-09-22", "start_date": "2018-08-08", "web_url": "https://gitlab.example.com/my-group/my-project/milestones/1" }, "merge_when_pipeline_succeeds": true, "merge_status": "can_be_merged", "sha": "8888888888888888888888888888888888888888", "merge_commit_sha": null, "squash_commit_sha": null, "user_notes_count": 1, "discussion_locked": null, "should_remove_source_branch": true, "force_remove_source_branch": false, "allow_collaboration": false, "allow_maintainer_to_push": false, "web_url": "http://gitlab.example.com/my-group/my-project/merge_requests/1", "references": { "short": "!1", "relative": "!1", "full": "my-group/my-project!1" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "squash": false, "subscribed": false, "changes_count": "1", "merged_by": { "id": 87854, "name": "Douwe Maan", "username": "DouweM", "state": "active", "avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png", "web_url": "https://gitlab.com/DouweM" }, "merged_at": "2018-09-07T11:16:17.520Z", "closed_by": null, "closed_at": null, "latest_build_started_at": "2018-09-07T07:27:38.472Z", "latest_build_finished_at": "2018-09-07T08:07:06.012Z", "first_deployed_to_production_at": null, "pipeline": { "id": 29626725, "sha": "2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f", "ref": "patch-28", "status": "success", "web_url": "https://gitlab.example.com/my-group/my-project/pipelines/29626725" }, "diff_refs": { "base_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00", "head_sha": "2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f", "start_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00" }, "diverged_commits_count": 2, "task_completion_status":{ "count":0, "completed_count":0 } } ``` 在 GitLab 用戶[入門,青銅或更高](https://about.gitlab.com/pricing/)還會看到`approvals_before_merge`參數: ``` { "id": 1, "title": "test1", "approvals_before_merge": null ... } ``` ## Create a todo[](#create-a-todo "Permalink") 在合并請求上為當前用戶手動創建待辦事項. 如果在該合并請求上已經存在用戶的待辦事項,則返回狀態碼`304` . ``` POST /projects/:id/merge_requests/:merge_request_iid/todo ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) | | `merge_request_iid` | integer | yes | 合并請求的內部 ID | ``` curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/27/todo" ``` 響應示例: ``` { "id": 113, "project": { "id": 3, "name": "GitLab CI/CD", "name_with_namespace": "GitLab Org / GitLab CI/CD", "path": "gitlab-ci", "path_with_namespace": "gitlab-org/gitlab-ci" }, "author": { "name": "Administrator", "username": "root", "id": 1, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "web_url": "https://gitlab.example.com/root" }, "action_name": "marked", "target_type": "MergeRequest", "target": { "id": 27, "iid": 7, "project_id": 3, "title": "Et voluptas laudantium minus nihil recusandae ut accusamus earum aut non.", "description": "Veniam sunt nihil modi earum cumque illum delectus. Nihil ad quis distinctio quia. Autem eligendi at quibusdam repellendus.", "state": "merged", "created_at": "2016-06-17T07:48:04.330Z", "updated_at": "2016-07-01T11:14:15.537Z", "target_branch": "allow_regex_for_project_skip_ref", "source_branch": "backup", "upvotes": 0, "downvotes": 0, "author": { "name": "Jarret O'Keefe", "username": "francisca", "id": 14, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/a7fa515d53450023c83d62986d0658a8?s=80&d=identicon", "web_url": "https://gitlab.example.com/francisca", "discussion_locked": false }, "assignee": { "name": "Dr. Gabrielle Strosin", "username": "barrett.krajcik", "id": 4, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/733005fcd7e6df12d2d8580171ccb966?s=80&d=identicon", "web_url": "https://gitlab.example.com/barrett.krajcik" }, "assignees": [{ "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }], "source_project_id": 3, "target_project_id": 3, "labels": [], "work_in_progress": false, "milestone": { "id": 27, "iid": 2, "project_id": 3, "title": "v1.0", "description": "Quis ea accusantium animi hic fuga assumenda.", "state": "active", "created_at": "2016-06-17T07:47:33.840Z", "updated_at": "2016-06-17T07:47:33.840Z", "due_date": null }, "merge_when_pipeline_succeeds": false, "merge_status": "unchecked", "subscribed": true, "sha": "8888888888888888888888888888888888888888", "merge_commit_sha": null, "squash_commit_sha": null, "user_notes_count": 7, "changes_count": "1", "should_remove_source_branch": true, "force_remove_source_branch": false, "squash": false, "web_url": "http://example.com/my-group/my-project/merge_requests/1", "references": { "short": "!1", "relative": "!1", "full": "my-group/my-project!1" }, }, "target_url": "https://gitlab.example.com/gitlab-org/gitlab-ci/merge_requests/7", "body": "Et voluptas laudantium minus nihil recusandae ut accusamus earum aut non.", "state": "pending", "created_at": "2016-07-01T11:14:15.530Z" } ``` ## Get MR diff versions[](#get-mr-diff-versions "Permalink") 獲取合并請求差異版本的列表. ``` GET /projects/:id/merge_requests/:merge_request_iid/versions ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | String | yes | 項目 ID | | `merge_request_iid` | integer | yes | 合并請求的內部 ID | ``` curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/merge_requests/1/versions" ``` 響應示例: ``` [{ "id": 110, "head_commit_sha": "33e2ee8579fda5bc36accc9c6fbd0b4fefda9e30", "base_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd", "start_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd", "created_at": "2016-07-26T14:44:48.926Z", "merge_request_id": 105, "state": "collected", "real_size": "1" }, { "id": 108, "head_commit_sha": "3eed087b29835c48015768f839d76e5ea8f07a24", "base_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd", "start_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd", "created_at": "2016-07-25T14:21:33.028Z", "merge_request_id": 105, "state": "collected", "real_size": "1" }] ``` ## Get a single MR diff version[](#get-a-single-mr-diff-version "Permalink") 獲取單個合并請求的差異版本. ``` GET /projects/:id/merge_requests/:merge_request_iid/versions/:version_id ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | String | yes | 項目 ID | | `merge_request_iid` | integer | yes | 合并請求的內部 ID | | `version_id` | integer | yes | 合并請求差異版本的 ID | ``` curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/merge_requests/1/versions/1" ``` 響應示例: ``` { "id": 110, "head_commit_sha": "33e2ee8579fda5bc36accc9c6fbd0b4fefda9e30", "base_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd", "start_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd", "created_at": "2016-07-26T14:44:48.926Z", "merge_request_id": 105, "state": "collected", "real_size": "1", "commits": [{ "id": "33e2ee8579fda5bc36accc9c6fbd0b4fefda9e30", "short_id": "33e2ee85", "title": "Change year to 2018", "author_name": "Administrator", "author_email": "admin@example.com", "created_at": "2016-07-26T17:44:29.000+03:00", "message": "Change year to 2018" }, { "id": "aa24655de48b36335556ac8a3cd8bb521f977cbd", "short_id": "aa24655d", "title": "Update LICENSE", "author_name": "Administrator", "author_email": "admin@example.com", "created_at": "2016-07-25T17:21:53.000+03:00", "message": "Update LICENSE" }, { "id": "3eed087b29835c48015768f839d76e5ea8f07a24", "short_id": "3eed087b", "title": "Add license", "author_name": "Administrator", "author_email": "admin@example.com", "created_at": "2016-07-25T17:21:20.000+03:00", "message": "Add license" }], "diffs": [{ "old_path": "LICENSE", "new_path": "LICENSE", "a_mode": "0", "b_mode": "100644", "diff": "--- /dev/null\n+++ b/LICENSE\n@@ -0,0 +1,21 @@\n+The MIT License (MIT)\n+\n+Copyright (c) 2018 Administrator\n+\n+Permission is hereby granted, free of charge, to any person obtaining a copy\n+of this software and associated documentation files (the \"Software\"), to deal\n+in the Software without restriction, including without limitation the rights\n+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+copies of the Software, and to permit persons to whom the Software is\n+furnished to do so, subject to the following conditions:\n+\n+The above copyright notice and this permission notice shall be included in all\n+copies or substantial portions of the Software.\n+\n+THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+SOFTWARE.\n", "new_file": true, "renamed_file": false, "deleted_file": false }] } ``` ## Set a time estimate for a merge request[](#set-a-time-estimate-for-a-merge-request "Permalink") Sets an estimated time of work for this merge request. ``` POST /projects/:id/merge_requests/:merge_request_iid/time_estimate ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) | | `merge_request_iid` | integer | yes | 合并請求的內部 ID | | `duration` | string | yes | 以人類格式表示的持續時間. 例如:3h30m | ``` curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/93/time_estimate?duration=3h30m" ``` 響應示例: ``` { "human_time_estimate": "3h 30m", "human_total_time_spent": null, "time_estimate": 12600, "total_time_spent": 0 } ``` ## Reset the time estimate for a merge request[](#reset-the-time-estimate-for-a-merge-request "Permalink") 將此合并請求的估計時間重置為 0 秒. ``` POST /projects/:id/merge_requests/:merge_request_iid/reset_time_estimate ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) | | `merge_request_iid` | integer | yes | 項目的 merge_request 的內部 ID | ``` curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/93/reset_time_estimate" ``` 響應示例: ``` { "human_time_estimate": null, "human_total_time_spent": null, "time_estimate": 0, "total_time_spent": 0 } ``` ## Add spent time for a merge request[](#add-spent-time-for-a-merge-request "Permalink") 增加此合并請求的時間 ``` POST /projects/:id/merge_requests/:merge_request_iid/add_spent_time ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) | | `merge_request_iid` | integer | yes | 合并請求的內部 ID | | `duration` | string | yes | 以人類格式表示的持續時間. 例如:3h30m | ``` curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/93/add_spent_time?duration=1h" ``` 響應示例: ``` { "human_time_estimate": null, "human_total_time_spent": "1h", "time_estimate": 0, "total_time_spent": 3600 } ``` ## Reset spent time for a merge request[](#reset-spent-time-for-a-merge-request "Permalink") 將此合并請求的總花費時間重置為 0 秒. ``` POST /projects/:id/merge_requests/:merge_request_iid/reset_spent_time ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) | | `merge_request_iid` | integer | yes | 項目的 merge_request 的內部 ID | ``` curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/93/reset_spent_time" ``` 響應示例: ``` { "human_time_estimate": null, "human_total_time_spent": null, "time_estimate": 0, "total_time_spent": 0 } ``` ## Get time tracking stats[](#get-time-tracking-stats "Permalink") ``` GET /projects/:id/merge_requests/:merge_request_iid/time_stats ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 經過身份驗證的用戶擁有[的項目](README.html#namespaced-path-encoding)的 ID 或[URL 編碼路徑](README.html#namespaced-path-encoding) | | `merge_request_iid` | integer | yes | 合并請求的內部 ID | ``` curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/93/time_stats" ``` 響應示例: ``` { "human_time_estimate": "2h", "human_total_time_spent": "1h", "time_estimate": 7200, "total_time_spent": 3600 } ``` ## Approvals[](#approvals-starter "Permalink") 有關批準,請參閱[合并請求批準](merge_request_approvals.html)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看