#[non_exhaustive]pub struct ProtectionSpec {
pub required_check: String,
pub require_pull_request: bool,
pub block_force_push: bool,
pub block_deletion: bool,
pub require_status_check: bool,
pub require_code_owner_review: bool,
pub protected_paths: Vec<String>,
}Expand description
Branch protection to enforce on the default branch.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.required_check: StringThe status check that must pass.
require_pull_request: boolChanges must come through a pull request.
block_force_push: boolBlock force-pushes.
block_deletion: boolBlock deletion.
require_status_check: boolRequire ProtectionSpec::required_check in this rule. false when
the check is enforced at the namespace level instead (a required
workflow, StepAction::RequireNamespaceWorkflow), so this rule
carries only the PR, force-push and deletion parts.
require_code_owner_review: boolPull requests need an approving review, including a code owner’s for
files that have one (StepAction::RequireOwnerReview).
protected_paths: Vec<String>Paths (forge glob syntax) a pull request may not change and still merge: the workflows and the exempt keyring. Without this a PR could rewrite the check it is judged by — CI runs the PR’s own copy of the workflow — and pass itself. Empty where the forge enforces this some other way or not at all.
Implementations§
Source§impl ProtectionSpec
impl ProtectionSpec
Sourcepub fn standard(check: impl Into<String>) -> Self
pub fn standard(check: impl Into<String>) -> Self
The §5.3 protection: PR required, check required, no force-push, no
deletion. There is deliberately no bypass field — the design allows
no bypass actors, so there is nothing to configure.
Sourcepub fn with_protected_paths<I, S>(self, paths: I) -> Self
pub fn with_protected_paths<I, S>(self, paths: I) -> Self
Also forbid pull requests that change paths.
Sourcepub fn with_check_enforced_by_namespace(self) -> Self
pub fn with_check_enforced_by_namespace(self) -> Self
Leave the check out of this rule: a namespace-level required workflow enforces it.
Sourcepub fn with_code_owner_review(self) -> Self
pub fn with_code_owner_review(self) -> Self
Require an approving review, and a code owner’s where one is named.