获取项目合并请求设置
功能介绍
获取项目合并请求设置
调试
您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。
URI
GET /v4/projects/{project_id}/merge-requests/setting
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释: 项目的32位uuid,项目唯一标识,通过查询项目列表接口查询项目列表获取。 取值范围: 字符串长度32。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
参数解释: 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 约束限制: 必传。 取值范围: 字符串长度不少于1,不超过10万。 默认取值: 不涉及。 |
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
id |
Integer |
参数解释: 主键id 取值范围: 1-2147483647 |
disable_merge_by_self |
Boolean |
参数解释: 禁止合入自己创建的合并请求 |
disable_approve_by_self |
Boolean |
参数解释: 禁止审核自己创建的合并请求 |
disable_review_by_self |
Boolean |
参数解释: 禁止检视自己创建的合并请求 |
created_at |
String |
参数解释: 创建时间。 |
updated_at |
String |
参数解释: 更新时间。 |
can_force_merge |
Boolean |
参数解释: 允许仓库管理员及项目经理强制合入 |
disable_squash_merge |
Boolean |
参数解释: 禁止Squash合并(合入MR时禁止Squash合并) |
must_relate_issue |
Boolean |
参数解释: 必须与CodeArts Req关联 |
need_relate_issue_branches |
String |
参数解释: 必须与CodeArts Req关联-选择目标分支配置合并请求策略(分支以逗号分支的字符串) |
need_all_issues_check_passed |
Boolean |
参数解释: 必须与CodeArts Req关联-所有E2E单号校验必须通过 |
review_mode |
String |
参数解释: 合入模式 枚举值:
|
add_notes_after_merged |
Boolean |
参数解释: 允许合并请求合并或关闭后继续做代码检视和评论 |
merged_commit_author |
String |
参数解释: merged_by:使用MR合入者生成Merge Commit created_by:使用MR创建者生成Merge Commit 枚举值:
|
evaluation_role |
Integer |
参数解释: 是否将星级评价作为合入门禁-参与星级评价角色。 29:勾选开发者 30:勾选开发者,Committer 35:勾选Committer 40:都不勾选 枚举值:
|
evaluation_merge_gate |
Boolean |
参数解释: 是否将星级评价作为合入门禁 |
mark_auto_merged_mr_as_closed |
Boolean |
参数解释: 是否将自动合并的MR状态标记为关闭状态 |
delete_source_branch_when_merged |
Boolean |
参数解释: 新建合并请求,默认开启合并后删除源分支 |
auto_squash_merge |
Boolean |
参数解释: 新建合并请求,默认开启Squash合并 |
squash_merge_with_no_merge_commit |
Boolean |
参数解释: Squash合并不产生Merge节点 |
only_allow_one_issue_check_passed |
Boolean |
参数解释: 只能关联一个单号 |
enable_custom_evaluation |
Boolean |
参数解释: 启用MR自定义评价维度分类(MR评价设置) |
evaluation_types |
Array of EvaluationTypeDto objects |
参数解释: 评价维度(MR评价设置) |
can_reopen |
Boolean |
参数解释: 不能重新打开一个已经关闭的合并请求 |
only_allow_merge_if_all_discussions_are_resolved |
Boolean |
参数解释: 评审问题全部解决才能合入 |
merge_method |
String |
参数解释: 合并模式。 merge:通过 Merge Commit 合并 rebase_merge:通过 Merge Commit 合并(记录半线性历史) ff:Fast-forward 合并 枚举值:
|
only_allow_merge_if_vote_bigger_than |
Integer |
参数解释: 打分模式最低合入分数。 取值范围: 0-5 |
only_assignee_can_merge |
Boolean |
参数解释: 仅合并人和合并合并请求。 |
project_id |
String |
参数解释: 项目id。 |
参数 |
参数类型 |
描述 |
---|---|---|
id |
Integer |
参数解释: 自定义评价主键id 取值范围: 1-2147483647 |
name |
String |
参数解释: 自定义评价名称 |
状态码:401
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
参数解释: 错误码。 |
error_msg |
String |
参数解释: 错误信息。 |
请求示例
无
响应示例
状态码:200
OK
{ "id" : 3223015, "project_id" : "4f96a4f00f17466bab756a2379236c85", "disable_merge_by_self" : false, "disable_review_by_self" : false, "disable_approve_by_self" : false, "created_at" : "2025-02-25T19:44:44.000+08:00", "updated_at" : "2025-02-25T20:07:32.000+08:00", "can_force_merge" : false, "disable_squash_merge" : false, "must_relate_issue" : false, "need_relate_issue_branches" : null, "need_all_issues_check_passed" : false, "review_mode" : "vote", "add_notes_after_merged" : false, "merged_commit_author" : "created_by", "evaluation_role" : 35, "evaluation_merge_gate" : true, "mark_auto_merged_mr_as_closed" : false, "delete_source_branch_when_merged" : false, "auto_squash_merge" : true, "squash_merge_with_no_merge_commit" : false, "only_allow_one_issue_check_passed" : false, "enable_custom_evaluation" : true, "evaluation_types" : [ { "id" : 32, "name" : "a" }, { "id" : 33, "name" : "b" } ], "can_reopen" : true, "only_allow_merge_if_all_discussions_are_resolved" : false, "merge_method" : "ff", "only_allow_merge_if_vote_bigger_than" : 0, "only_assignee_can_merge" : true }
状态码:401
Unauthorized
{ "error_code" : "DEV.00000003", "error_msg" : "认证信息过期" }
SDK代码示例
SDK代码示例如下。
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.codehub.v4.region.CodeHubRegion; import com.huaweicloud.sdk.codehub.v4.*; import com.huaweicloud.sdk.codehub.v4.model.*; public class ShowProjectMergeRequestSettingSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); CodeHubClient client = CodeHubClient.newBuilder() .withCredential(auth) .withRegion(CodeHubRegion.valueOf("<YOUR REGION>")) .build(); ShowProjectMergeRequestSettingRequest request = new ShowProjectMergeRequestSettingRequest(); request.withProjectId("{project_id}"); try { ShowProjectMergeRequestSettingResponse response = client.showProjectMergeRequestSetting(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcodehub.v4.region.codehub_region import CodeHubRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcodehub.v4 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] credentials = BasicCredentials(ak, sk) client = CodeHubClient.new_builder() \ .with_credentials(credentials) \ .with_region(CodeHubRegion.value_of("<YOUR REGION>")) \ .build() try: request = ShowProjectMergeRequestSettingRequest() request.project_id = "{project_id}" response = client.show_project_merge_request_setting(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" codehub "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codehub/v4" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codehub/v4/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codehub/v4/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := codehub.NewCodeHubClient( codehub.CodeHubClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ShowProjectMergeRequestSettingRequest{} request.ProjectId = "{project_id}" response, err := client.ShowProjectMergeRequestSetting(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
OK |
401 |
Unauthorized |
错误码
请参见错误码。