Skip to content

Commit

Permalink
Add new branch protection values (#1393)
Browse files Browse the repository at this point in the history
Fixes #1345.
Closes #1354.
  • Loading branch information
tjamet authored and gmlewis committed Jan 24, 2020
1 parent e7361de commit 8f818bc
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
48 changes: 48 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions github/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,9 @@ type Protection struct {
RequiredPullRequestReviews *PullRequestReviewsEnforcement `json:"required_pull_request_reviews"`
EnforceAdmins *AdminEnforcement `json:"enforce_admins"`
Restrictions *BranchRestrictions `json:"restrictions"`
RequireLinearHistory *RequireLinearHistory `json:"required_linear_history"`
AllowForcePushes *AllowForcePushes `json:"allow_force_pushes"`
AllowDeletions *AllowDeletions `json:"allow_deletions"`
}

// ProtectionRequest represents a request to create/edit a branch's protection.
Expand All @@ -735,6 +738,12 @@ type ProtectionRequest struct {
RequiredPullRequestReviews *PullRequestReviewsEnforcementRequest `json:"required_pull_request_reviews"`
EnforceAdmins bool `json:"enforce_admins"`
Restrictions *BranchRestrictionsRequest `json:"restrictions"`
// Enforces a linear commit Git history, which prevents anyone from pushing merge commits to a branch.
RequireLinearHistory *bool `json:"required_linear_history,omitempty"`
// Permits force pushes to the protected branch by anyone with write access to the repository.
AllowForcePushes *bool `json:"allow_force_pushes,omitempty"`
// Allows deletion of the protected branch by anyone with write access to the repository.
AllowDeletions *bool `json:"allow_deletions,omitempty"`
}

// RequiredStatusChecks represents the protection status of a individual branch.
Expand Down Expand Up @@ -797,6 +806,21 @@ type PullRequestReviewsEnforcementUpdate struct {
RequiredApprovingReviewCount int `json:"required_approving_review_count"`
}

// RequireLinearHistory represents the configuration to enfore branches with no merge commit.
type RequireLinearHistory struct {
Enabled bool `json:"enabled"`
}

// AllowDeletions represents the configuration to accept deletion of protected branches.
type AllowDeletions struct {
Enabled bool `json:"enabled"`
}

// AllowForcePushes represents the configuration to accept forced pushes on protected branches.
type AllowForcePushes struct {
Enabled bool `json:"enabled"`
}

// AdminEnforcement represents the configuration to enforce required status checks for repository administrators.
type AdminEnforcement struct {
URL *string `json:"url,omitempty"`
Expand Down

0 comments on commit 8f818bc

Please sign in to comment.