GitSettings

创建保护分支规则。Create branch protection rule.

为指定仓库创建保护分支规则。每个仓库最多支持 10 条保护分支规则。需要仓库 Master 权限。创建成功后返回 201 状态码。 Create a branch protection rule for the specified repository. Maximum 10 rules per repository. Requires Master permission. Returns 201 on success. 访问令牌调用此接口需包含以下权限。Required permissions for access token. repo-manage:rw

post/{repo}/-/settings/branch-protections

Request

  • Base URL: https://api.cnb.cool (the document declares no server; this is the origin it was published from)
  • URL: https://api.cnb.cool/{repo}/-/settings/branch-protections
  • Auth: API key in header Authorization

Path parameters

repostring required

不带.git后缀的仓库名称。格式:组织名称/仓库名称。Repository name without .git suffix. Format: org/repo.

Request body

allow_creationboolean

是否允许所有人创建保护分支。Whether all users can create protected branches.

allow_deletionsboolean

是否允许所有人删除保护分支。Whether all users can delete protected branches.

allow_force_pushesboolean

是否允许所有人强制推送。Whether all users can force push.

allow_master_creationboolean

是否仅允许仓库管理员及负责人创建保护分支。Only admins/owners can create protected branches.

allow_master_deletionsboolean

是否仅允许仓库管理员及负责人删除保护分支。Only admins/owners can delete protected branches.

allow_master_force_pushesboolean

是否仅允许仓库管理员及负责人强制推送。Whether only repo admins and owners can force push.

allow_master_manual_mergeboolean

是否允许仓库管理员及负责人手动合并到目标分支。Admins/owners can manually merge to target branch.

allow_master_pushesboolean

是否仅允许仓库管理员及负责人推送代码到保护分支中。Only admins/owners can push to protected branches.

allow_pushesboolean

是否允许所有人推送代码到保护分支中。Whether all users can push to protected branches.

forbid_approve_pull_created_by_own_npcboolean
idstring

保护分支规则唯一标识符。Protected branch rule unique identifier.

required_approved_review_countinteger

需要的代码评审者数量。格式:评审者数量 ∈ [1,5]。Required reviewers count. ∈ [1,5].

required_approved_review_ratiointeger

需要的评审通过率。格式:通过率 ∈ [1, 100]。Required approval rate. ∈ [1, 100].

required_linear_historyboolean

是否仅允许线性提交。Whether only linear commits are allowed.

required_master_approveboolean

是否需至少一个仓库管理员批准。Whether at least one repo admin approval is required.

required_must_auto_mergeboolean

是否仅允许自动合并。Whether only auto-merge is allowed.

required_must_push_via_pull_requestboolean

是否必须通过合并请求推送代码到此规则匹配分支中。Push must be via merge requests.

required_pull_request_reviewsboolean

保护分支的合并请求是否需要代码评审。Code review required for merge requests.

required_status_checksboolean

是否需要通过状态检查。Whether status checks are required.

rulestring

保护分支规则名称,支持通配符。Protected branch rule name. Supports wildcards.

Response

Created

Changes

No recorded changes to this operation across all 1 revision of this API.