From c9fc7c9c4bed5f116bd5c85608d77a2606805edb Mon Sep 17 00:00:00 2001 From: Madhura Bhogate Date: Tue, 21 Sep 2021 17:34:53 -0700 Subject: [PATCH 01/23] chore: added BranchProtectionRuleEvent --- github/event.go | 2 ++ github/event_types.go | 13 +++++++++++++ github/messages.go | 1 + github/messages_test.go | 4 ++++ github/repos.go | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+) diff --git a/github/event.go b/github/event.go index 8f1a0f2eeae..9241d0286d8 100644 --- a/github/event.go +++ b/github/event.go @@ -30,6 +30,8 @@ func (e Event) String() string { // a value of the corresponding struct type will be returned. func (e *Event) ParsePayload() (payload interface{}, err error) { switch *e.Type { + case "BranchProtectionRuleEvent": + payload = &BranchProtectionRuleEvent{} case "CheckRunEvent": payload = &CheckRunEvent{} case "CheckSuiteEvent": diff --git a/github/event_types.go b/github/event_types.go index e55685c7b4e..83a6dd14008 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -15,6 +15,19 @@ type RequestedAction struct { Identifier string `json:"identifier"` // The integrator reference of the action requested by the user. } +// BranchProtectionEvent triggered when a check suite is "created", "edited", or "deleted". +// The Webhook event name is "branch_protection". +// +// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#branch_protection_rule +type BranchProtectionRuleEvent struct { + Action *string `json:"action,omitempty"` + Rule *ProtectionRules `json:"rule,omitempty"` + Changes *ProtectionChanges `json:"changes,omitempty"` + Repo *Repository `json:"repository,omitempty"` + Org *Organization `json:"organization,omitempty"` + Sender *User `json:"sender,omitempty"` +} + // CheckRunEvent is triggered when a check run is "created", "completed", or "rerequested". // The Webhook event name is "check_run". // diff --git a/github/messages.go b/github/messages.go index e46435c9a04..01c8b12c4cb 100644 --- a/github/messages.go +++ b/github/messages.go @@ -45,6 +45,7 @@ const ( var ( // eventTypeMapping maps webhooks types to their corresponding go-github struct types. eventTypeMapping = map[string]string{ + "branch_protection_rule": "BranchProtectionRuleEvent", "check_run": "CheckRunEvent", "check_suite": "CheckSuiteEvent", "commit_comment": "CommitCommentEvent", diff --git a/github/messages_test.go b/github/messages_test.go index da8c3331564..491cbbaf538 100644 --- a/github/messages_test.go +++ b/github/messages_test.go @@ -261,6 +261,10 @@ func TestParseWebHook(t *testing.T) { payload interface{} messageType string }{ + { + payload: &BranchProtectionRuleEvent{}, + messageType: "branch_protection_rule", + }, { payload: &CheckRunEvent{}, messageType: "check_run", diff --git a/github/repos.go b/github/repos.go index aab18d4d459..326046d3e96 100644 --- a/github/repos.go +++ b/github/repos.go @@ -767,6 +767,46 @@ type Protection struct { RequiredConversationResolution *RequiredConversationResolution `json:"required_conversation_resolution"` } +type ProtectionRules struct { + ID *int64 `json:"id,omitempty"` + RepositoryID *int64 `json:"repository_id,omitempty"` + Name *string `json:"name,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + PullRequestReviewsEnforcementLevel *string `json:"pull_request_reviews_enforcement_level,omitempty"` + RequiredApprovingReviewCount int `json:"required_approving_review_count"` + DismissStaleReviewsonPush bool `json:"dismiss_stale_reviews_on_push"` + AuthorizedDismissalActors bool `json:"authorized_dismissal_actors_only"` + IgnoreApprovalsFromContributors bool `json:"ignore_approvals_from_contributors"` + RequireCodeOwnerReviews bool `json:"require_code_owner_reviews,omitempty"` + RequiredStatusChecks []string `json:"required_status_checks,omitempty"` + StatusChecksEnforcementLevel *string `json:"required_status_checks_enforcement_level,omitempty"` + StrictRequiredStatusChecksPolicy bool `json:"strict_required_status_checks_policy"` + LinearHistoryEnforcementLevel *string `json:"linear_history_requirement_enforcement_level,omitempty"` + AdminEnforced bool `json:"admin_enforced"` + ForcePushesEnforcementLevel *string `json:"allow_force_pushes_enforcement_level,omitempty"` + DeletionsEnforcementLevel *string `json:"allow_deletions_enforcement_level,omitempty"` + MergeQueueEnforcementLevel *string `json:"merge_queue_enforcement_level,omitempty"` + DeploymentEnforcementLevel *string `json:"required_deployments_enforcement_level,omitempty"` + ConversationResolutionLevel *string `json:"required_conversation_resolution_level,omitempty"` + AuthorizedActorsOnly bool `json:"authorized_actors_only"` + AuthorizedActorNames []string `json:"authorized_actor_names,omitempty"` +} + +// If the BranchProtection was edited, the changes to the rule +type ProtectionChanges struct { + AuthorizedActorsOnly *AuthorizedActorsOnly `json:"authorized_actors_only"` + AuthorizedActorNames *AuthorizedActorNames `json:"authorized_actor_names,omitempty"` +} + +type AuthorizedActorNames struct { + From []string `json:"from"` +} + +type AuthorizedActorsOnly struct { + From bool `json:"from"` +} + // ProtectionRequest represents a request to create/edit a branch's protection. type ProtectionRequest struct { RequiredStatusChecks *RequiredStatusChecks `json:"required_status_checks"` From d9af37bfa845409cd2addabcccc80edb432228fe Mon Sep 17 00:00:00 2001 From: Madhura Bhogate Date: Tue, 21 Sep 2021 20:42:49 -0700 Subject: [PATCH 02/23] chore: added go generated files --- github/github-accessors.go | 168 ++++++++++++++++++++++++++++ github/github-accessors_test.go | 189 ++++++++++++++++++++++++++++++++ 2 files changed, 357 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index d57c57c27f8..fbc7af1ed8c 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -1364,6 +1364,54 @@ func (b *BranchPolicy) GetProtectedBranches() bool { return *b.ProtectedBranches } +// GetAction returns the Action field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRuleEvent) GetAction() string { + if b == nil || b.Action == nil { + return "" + } + return *b.Action +} + +// GetChanges returns the Changes field. +func (b *BranchProtectionRuleEvent) GetChanges() *ProtectionChanges { + if b == nil { + return nil + } + return b.Changes +} + +// GetOrg returns the Org field. +func (b *BranchProtectionRuleEvent) GetOrg() *Organization { + if b == nil { + return nil + } + return b.Org +} + +// GetRepo returns the Repo field. +func (b *BranchProtectionRuleEvent) GetRepo() *Repository { + if b == nil { + return nil + } + return b.Repo +} + +// GetRule returns the Rule field. +func (b *BranchProtectionRuleEvent) GetRule() *ProtectionRules { + if b == nil { + return nil + } + return b.Rule +} + +// GetSender returns the Sender field. +func (b *BranchProtectionRuleEvent) GetSender() *User { + if b == nil { + return nil + } + return b.Sender +} + // GetApp returns the App field. func (c *CheckRun) GetApp() *App { if c == nil { @@ -10508,6 +10556,22 @@ func (p *Protection) GetRestrictions() *BranchRestrictions { return p.Restrictions } +// GetAuthorizedActorNames returns the AuthorizedActorNames field. +func (p *ProtectionChanges) GetAuthorizedActorNames() *AuthorizedActorNames { + if p == nil { + return nil + } + return p.AuthorizedActorNames +} + +// GetAuthorizedActorsOnly returns the AuthorizedActorsOnly field. +func (p *ProtectionChanges) GetAuthorizedActorsOnly() *AuthorizedActorsOnly { + if p == nil { + return nil + } + return p.AuthorizedActorsOnly +} + // GetAllowDeletions returns the AllowDeletions field if it's non-nil, zero value otherwise. func (p *ProtectionRequest) GetAllowDeletions() bool { if p == nil || p.AllowDeletions == nil { @@ -10596,6 +10660,110 @@ func (p *ProtectionRule) GetWaitTimer() int { return *p.WaitTimer } +// GetConversationResolutionLevel returns the ConversationResolutionLevel field if it's non-nil, zero value otherwise. +func (p *ProtectionRules) GetConversationResolutionLevel() string { + if p == nil || p.ConversationResolutionLevel == nil { + return "" + } + return *p.ConversationResolutionLevel +} + +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (p *ProtectionRules) GetCreatedAt() Timestamp { + if p == nil || p.CreatedAt == nil { + return Timestamp{} + } + return *p.CreatedAt +} + +// GetDeletionsEnforcementLevel returns the DeletionsEnforcementLevel field if it's non-nil, zero value otherwise. +func (p *ProtectionRules) GetDeletionsEnforcementLevel() string { + if p == nil || p.DeletionsEnforcementLevel == nil { + return "" + } + return *p.DeletionsEnforcementLevel +} + +// GetDeploymentEnforcementLevel returns the DeploymentEnforcementLevel field if it's non-nil, zero value otherwise. +func (p *ProtectionRules) GetDeploymentEnforcementLevel() string { + if p == nil || p.DeploymentEnforcementLevel == nil { + return "" + } + return *p.DeploymentEnforcementLevel +} + +// GetForcePushesEnforcementLevel returns the ForcePushesEnforcementLevel field if it's non-nil, zero value otherwise. +func (p *ProtectionRules) GetForcePushesEnforcementLevel() string { + if p == nil || p.ForcePushesEnforcementLevel == nil { + return "" + } + return *p.ForcePushesEnforcementLevel +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (p *ProtectionRules) GetID() int64 { + if p == nil || p.ID == nil { + return 0 + } + return *p.ID +} + +// GetLinearHistoryEnforcementLevel returns the LinearHistoryEnforcementLevel field if it's non-nil, zero value otherwise. +func (p *ProtectionRules) GetLinearHistoryEnforcementLevel() string { + if p == nil || p.LinearHistoryEnforcementLevel == nil { + return "" + } + return *p.LinearHistoryEnforcementLevel +} + +// GetMergeQueueEnforcementLevel returns the MergeQueueEnforcementLevel field if it's non-nil, zero value otherwise. +func (p *ProtectionRules) GetMergeQueueEnforcementLevel() string { + if p == nil || p.MergeQueueEnforcementLevel == nil { + return "" + } + return *p.MergeQueueEnforcementLevel +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (p *ProtectionRules) GetName() string { + if p == nil || p.Name == nil { + return "" + } + return *p.Name +} + +// GetPullRequestReviewsEnforcementLevel returns the PullRequestReviewsEnforcementLevel field if it's non-nil, zero value otherwise. +func (p *ProtectionRules) GetPullRequestReviewsEnforcementLevel() string { + if p == nil || p.PullRequestReviewsEnforcementLevel == nil { + return "" + } + return *p.PullRequestReviewsEnforcementLevel +} + +// GetRepositoryID returns the RepositoryID field if it's non-nil, zero value otherwise. +func (p *ProtectionRules) GetRepositoryID() int64 { + if p == nil || p.RepositoryID == nil { + return 0 + } + return *p.RepositoryID +} + +// GetStatusChecksEnforcementLevel returns the StatusChecksEnforcementLevel field if it's non-nil, zero value otherwise. +func (p *ProtectionRules) GetStatusChecksEnforcementLevel() string { + if p == nil || p.StatusChecksEnforcementLevel == nil { + return "" + } + return *p.StatusChecksEnforcementLevel +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (p *ProtectionRules) GetUpdatedAt() Timestamp { + if p == nil || p.UpdatedAt == nil { + return Timestamp{} + } + return *p.UpdatedAt +} + // GetInstallation returns the Installation field. func (p *PublicEvent) GetInstallation() *Installation { if p == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 51c3d155aa3..01a18955a2a 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -1631,6 +1631,51 @@ func TestBranchPolicy_GetProtectedBranches(tt *testing.T) { b.GetProtectedBranches() } +func TestBranchProtectionRuleEvent_GetAction(tt *testing.T) { + var zeroValue string + b := &BranchProtectionRuleEvent{Action: &zeroValue} + b.GetAction() + b = &BranchProtectionRuleEvent{} + b.GetAction() + b = nil + b.GetAction() +} + +func TestBranchProtectionRuleEvent_GetChanges(tt *testing.T) { + b := &BranchProtectionRuleEvent{} + b.GetChanges() + b = nil + b.GetChanges() +} + +func TestBranchProtectionRuleEvent_GetOrg(tt *testing.T) { + b := &BranchProtectionRuleEvent{} + b.GetOrg() + b = nil + b.GetOrg() +} + +func TestBranchProtectionRuleEvent_GetRepo(tt *testing.T) { + b := &BranchProtectionRuleEvent{} + b.GetRepo() + b = nil + b.GetRepo() +} + +func TestBranchProtectionRuleEvent_GetRule(tt *testing.T) { + b := &BranchProtectionRuleEvent{} + b.GetRule() + b = nil + b.GetRule() +} + +func TestBranchProtectionRuleEvent_GetSender(tt *testing.T) { + b := &BranchProtectionRuleEvent{} + b.GetSender() + b = nil + b.GetSender() +} + func TestCheckRun_GetApp(tt *testing.T) { c := &CheckRun{} c.GetApp() @@ -12266,6 +12311,20 @@ func TestProtection_GetRestrictions(tt *testing.T) { p.GetRestrictions() } +func TestProtectionChanges_GetAuthorizedActorNames(tt *testing.T) { + p := &ProtectionChanges{} + p.GetAuthorizedActorNames() + p = nil + p.GetAuthorizedActorNames() +} + +func TestProtectionChanges_GetAuthorizedActorsOnly(tt *testing.T) { + p := &ProtectionChanges{} + p.GetAuthorizedActorsOnly() + p = nil + p.GetAuthorizedActorsOnly() +} + func TestProtectionRequest_GetAllowDeletions(tt *testing.T) { var zeroValue bool p := &ProtectionRequest{AllowDeletions: &zeroValue} @@ -12367,6 +12426,136 @@ func TestProtectionRule_GetWaitTimer(tt *testing.T) { p.GetWaitTimer() } +func TestProtectionRules_GetConversationResolutionLevel(tt *testing.T) { + var zeroValue string + p := &ProtectionRules{ConversationResolutionLevel: &zeroValue} + p.GetConversationResolutionLevel() + p = &ProtectionRules{} + p.GetConversationResolutionLevel() + p = nil + p.GetConversationResolutionLevel() +} + +func TestProtectionRules_GetCreatedAt(tt *testing.T) { + var zeroValue Timestamp + p := &ProtectionRules{CreatedAt: &zeroValue} + p.GetCreatedAt() + p = &ProtectionRules{} + p.GetCreatedAt() + p = nil + p.GetCreatedAt() +} + +func TestProtectionRules_GetDeletionsEnforcementLevel(tt *testing.T) { + var zeroValue string + p := &ProtectionRules{DeletionsEnforcementLevel: &zeroValue} + p.GetDeletionsEnforcementLevel() + p = &ProtectionRules{} + p.GetDeletionsEnforcementLevel() + p = nil + p.GetDeletionsEnforcementLevel() +} + +func TestProtectionRules_GetDeploymentEnforcementLevel(tt *testing.T) { + var zeroValue string + p := &ProtectionRules{DeploymentEnforcementLevel: &zeroValue} + p.GetDeploymentEnforcementLevel() + p = &ProtectionRules{} + p.GetDeploymentEnforcementLevel() + p = nil + p.GetDeploymentEnforcementLevel() +} + +func TestProtectionRules_GetForcePushesEnforcementLevel(tt *testing.T) { + var zeroValue string + p := &ProtectionRules{ForcePushesEnforcementLevel: &zeroValue} + p.GetForcePushesEnforcementLevel() + p = &ProtectionRules{} + p.GetForcePushesEnforcementLevel() + p = nil + p.GetForcePushesEnforcementLevel() +} + +func TestProtectionRules_GetID(tt *testing.T) { + var zeroValue int64 + p := &ProtectionRules{ID: &zeroValue} + p.GetID() + p = &ProtectionRules{} + p.GetID() + p = nil + p.GetID() +} + +func TestProtectionRules_GetLinearHistoryEnforcementLevel(tt *testing.T) { + var zeroValue string + p := &ProtectionRules{LinearHistoryEnforcementLevel: &zeroValue} + p.GetLinearHistoryEnforcementLevel() + p = &ProtectionRules{} + p.GetLinearHistoryEnforcementLevel() + p = nil + p.GetLinearHistoryEnforcementLevel() +} + +func TestProtectionRules_GetMergeQueueEnforcementLevel(tt *testing.T) { + var zeroValue string + p := &ProtectionRules{MergeQueueEnforcementLevel: &zeroValue} + p.GetMergeQueueEnforcementLevel() + p = &ProtectionRules{} + p.GetMergeQueueEnforcementLevel() + p = nil + p.GetMergeQueueEnforcementLevel() +} + +func TestProtectionRules_GetName(tt *testing.T) { + var zeroValue string + p := &ProtectionRules{Name: &zeroValue} + p.GetName() + p = &ProtectionRules{} + p.GetName() + p = nil + p.GetName() +} + +func TestProtectionRules_GetPullRequestReviewsEnforcementLevel(tt *testing.T) { + var zeroValue string + p := &ProtectionRules{PullRequestReviewsEnforcementLevel: &zeroValue} + p.GetPullRequestReviewsEnforcementLevel() + p = &ProtectionRules{} + p.GetPullRequestReviewsEnforcementLevel() + p = nil + p.GetPullRequestReviewsEnforcementLevel() +} + +func TestProtectionRules_GetRepositoryID(tt *testing.T) { + var zeroValue int64 + p := &ProtectionRules{RepositoryID: &zeroValue} + p.GetRepositoryID() + p = &ProtectionRules{} + p.GetRepositoryID() + p = nil + p.GetRepositoryID() +} + +func TestProtectionRules_GetStatusChecksEnforcementLevel(tt *testing.T) { + var zeroValue string + p := &ProtectionRules{StatusChecksEnforcementLevel: &zeroValue} + p.GetStatusChecksEnforcementLevel() + p = &ProtectionRules{} + p.GetStatusChecksEnforcementLevel() + p = nil + p.GetStatusChecksEnforcementLevel() +} + +func TestProtectionRules_GetUpdatedAt(tt *testing.T) { + var zeroValue Timestamp + p := &ProtectionRules{UpdatedAt: &zeroValue} + p.GetUpdatedAt() + p = &ProtectionRules{} + p.GetUpdatedAt() + p = nil + p.GetUpdatedAt() +} + func TestPublicEvent_GetInstallation(tt *testing.T) { p := &PublicEvent{} p.GetInstallation() From 08e552dc2987e8a119a4409600285857af4c6918 Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:31:35 -0700 Subject: [PATCH 03/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index 326046d3e96..fab35cd9c74 100644 --- a/github/repos.go +++ b/github/repos.go @@ -800,7 +800,7 @@ type ProtectionChanges struct { } type AuthorizedActorNames struct { - From []string `json:"from"` + From []string `json:"from,omitempty"` } type AuthorizedActorsOnly struct { From 901852c7e165e68f55c8fd6124112aeb92332615 Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:31:45 -0700 Subject: [PATCH 04/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index fab35cd9c74..e38173bf2ad 100644 --- a/github/repos.go +++ b/github/repos.go @@ -804,7 +804,7 @@ type AuthorizedActorNames struct { } type AuthorizedActorsOnly struct { - From bool `json:"from"` + From *bool `json:"from,omitempty"` } // ProtectionRequest represents a request to create/edit a branch's protection. From e43aa76f65df4aee65771cf10f3c6dc4284288ee Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:32:01 -0700 Subject: [PATCH 05/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index e38173bf2ad..857d0548d97 100644 --- a/github/repos.go +++ b/github/repos.go @@ -795,7 +795,7 @@ type ProtectionRules struct { // If the BranchProtection was edited, the changes to the rule type ProtectionChanges struct { - AuthorizedActorsOnly *AuthorizedActorsOnly `json:"authorized_actors_only"` + AuthorizedActorsOnly *AuthorizedActorsOnly `json:"authorized_actors_only,omitempty"` AuthorizedActorNames *AuthorizedActorNames `json:"authorized_actor_names,omitempty"` } From a8197a6da1d460c51585aecf0b922fb5d8f9b14f Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:32:19 -0700 Subject: [PATCH 06/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index 857d0548d97..78989975079 100644 --- a/github/repos.go +++ b/github/repos.go @@ -775,7 +775,7 @@ type ProtectionRules struct { UpdatedAt *Timestamp `json:"updated_at,omitempty"` PullRequestReviewsEnforcementLevel *string `json:"pull_request_reviews_enforcement_level,omitempty"` RequiredApprovingReviewCount int `json:"required_approving_review_count"` - DismissStaleReviewsonPush bool `json:"dismiss_stale_reviews_on_push"` + DismissStaleReviewsOnPush *bool `json:"dismiss_stale_reviews_on_push,omitempty"` AuthorizedDismissalActors bool `json:"authorized_dismissal_actors_only"` IgnoreApprovalsFromContributors bool `json:"ignore_approvals_from_contributors"` RequireCodeOwnerReviews bool `json:"require_code_owner_reviews,omitempty"` From b6f61037357fb8b822093ce5c452879eb02138d2 Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:32:36 -0700 Subject: [PATCH 07/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index 78989975079..33943f5e4e4 100644 --- a/github/repos.go +++ b/github/repos.go @@ -767,7 +767,7 @@ type Protection struct { RequiredConversationResolution *RequiredConversationResolution `json:"required_conversation_resolution"` } -type ProtectionRules struct { +type ProtectionRule struct { ID *int64 `json:"id,omitempty"` RepositoryID *int64 `json:"repository_id,omitempty"` Name *string `json:"name,omitempty"` From b433722f6c22bfe2014f8d727862ebb4a3dfb741 Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:32:47 -0700 Subject: [PATCH 08/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index 33943f5e4e4..7dfae469950 100644 --- a/github/repos.go +++ b/github/repos.go @@ -774,7 +774,7 @@ type ProtectionRule struct { CreatedAt *Timestamp `json:"created_at,omitempty"` UpdatedAt *Timestamp `json:"updated_at,omitempty"` PullRequestReviewsEnforcementLevel *string `json:"pull_request_reviews_enforcement_level,omitempty"` - RequiredApprovingReviewCount int `json:"required_approving_review_count"` + RequiredApprovingReviewCount *int `json:"required_approving_review_count,omitempty"` DismissStaleReviewsOnPush *bool `json:"dismiss_stale_reviews_on_push,omitempty"` AuthorizedDismissalActors bool `json:"authorized_dismissal_actors_only"` IgnoreApprovalsFromContributors bool `json:"ignore_approvals_from_contributors"` From 8f043ee584b867411d73f1a34041a40ec1cfb31e Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:33:06 -0700 Subject: [PATCH 09/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index 7dfae469950..b083d2663a4 100644 --- a/github/repos.go +++ b/github/repos.go @@ -778,7 +778,7 @@ type ProtectionRule struct { DismissStaleReviewsOnPush *bool `json:"dismiss_stale_reviews_on_push,omitempty"` AuthorizedDismissalActors bool `json:"authorized_dismissal_actors_only"` IgnoreApprovalsFromContributors bool `json:"ignore_approvals_from_contributors"` - RequireCodeOwnerReviews bool `json:"require_code_owner_reviews,omitempty"` + RequireCodeOwnerReview *bool `json:"require_code_owner_review,omitempty"` RequiredStatusChecks []string `json:"required_status_checks,omitempty"` StatusChecksEnforcementLevel *string `json:"required_status_checks_enforcement_level,omitempty"` StrictRequiredStatusChecksPolicy bool `json:"strict_required_status_checks_policy"` From f0ebe6d1a7b8a78753bb1d7cd4af93a6667fd9c4 Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:33:13 -0700 Subject: [PATCH 10/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index b083d2663a4..22894f9e36b 100644 --- a/github/repos.go +++ b/github/repos.go @@ -776,7 +776,7 @@ type ProtectionRule struct { PullRequestReviewsEnforcementLevel *string `json:"pull_request_reviews_enforcement_level,omitempty"` RequiredApprovingReviewCount *int `json:"required_approving_review_count,omitempty"` DismissStaleReviewsOnPush *bool `json:"dismiss_stale_reviews_on_push,omitempty"` - AuthorizedDismissalActors bool `json:"authorized_dismissal_actors_only"` + AuthorizedDismissalActorsOnly *bool `json:"authorized_dismissal_actors_only,omitempty"` IgnoreApprovalsFromContributors bool `json:"ignore_approvals_from_contributors"` RequireCodeOwnerReview *bool `json:"require_code_owner_review,omitempty"` RequiredStatusChecks []string `json:"required_status_checks,omitempty"` From bccfa4ead331a0f3fadde0db20bcea14c0d38532 Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:33:29 -0700 Subject: [PATCH 11/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index 22894f9e36b..87505fca9bc 100644 --- a/github/repos.go +++ b/github/repos.go @@ -777,7 +777,7 @@ type ProtectionRule struct { RequiredApprovingReviewCount *int `json:"required_approving_review_count,omitempty"` DismissStaleReviewsOnPush *bool `json:"dismiss_stale_reviews_on_push,omitempty"` AuthorizedDismissalActorsOnly *bool `json:"authorized_dismissal_actors_only,omitempty"` - IgnoreApprovalsFromContributors bool `json:"ignore_approvals_from_contributors"` + IgnoreApprovalsFromContributors *bool `json:"ignore_approvals_from_contributors,omitempty"` RequireCodeOwnerReview *bool `json:"require_code_owner_review,omitempty"` RequiredStatusChecks []string `json:"required_status_checks,omitempty"` StatusChecksEnforcementLevel *string `json:"required_status_checks_enforcement_level,omitempty"` From f2a47d5b339e3d799a87b8de69bc2720976d86de Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:33:41 -0700 Subject: [PATCH 12/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index 87505fca9bc..edd215990b2 100644 --- a/github/repos.go +++ b/github/repos.go @@ -780,7 +780,7 @@ type ProtectionRule struct { IgnoreApprovalsFromContributors *bool `json:"ignore_approvals_from_contributors,omitempty"` RequireCodeOwnerReview *bool `json:"require_code_owner_review,omitempty"` RequiredStatusChecks []string `json:"required_status_checks,omitempty"` - StatusChecksEnforcementLevel *string `json:"required_status_checks_enforcement_level,omitempty"` + RequiredStatusChecksEnforcementLevel *string `json:"required_status_checks_enforcement_level,omitempty"` StrictRequiredStatusChecksPolicy bool `json:"strict_required_status_checks_policy"` LinearHistoryEnforcementLevel *string `json:"linear_history_requirement_enforcement_level,omitempty"` AdminEnforced bool `json:"admin_enforced"` From 57ff8ee2bfc41f309a3fedd41bd74456ef774d5f Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:33:55 -0700 Subject: [PATCH 13/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index edd215990b2..e635e120ff4 100644 --- a/github/repos.go +++ b/github/repos.go @@ -781,7 +781,8 @@ type ProtectionRule struct { RequireCodeOwnerReview *bool `json:"require_code_owner_review,omitempty"` RequiredStatusChecks []string `json:"required_status_checks,omitempty"` RequiredStatusChecksEnforcementLevel *string `json:"required_status_checks_enforcement_level,omitempty"` - StrictRequiredStatusChecksPolicy bool `json:"strict_required_status_checks_policy"` + StrictRequiredStatusChecksPolicy *bool `json:"strict_required_status_checks_policy,omitempty"` + SignatureRequirementEnforcementLevel *string `json:"signature_requirement_enforcement_level,omitempty"` LinearHistoryEnforcementLevel *string `json:"linear_history_requirement_enforcement_level,omitempty"` AdminEnforced bool `json:"admin_enforced"` ForcePushesEnforcementLevel *string `json:"allow_force_pushes_enforcement_level,omitempty"` From ddec5d902c8b37386faf8667a2ad49cbf024d709 Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:34:07 -0700 Subject: [PATCH 14/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index e635e120ff4..c8cc4ab2e80 100644 --- a/github/repos.go +++ b/github/repos.go @@ -783,7 +783,7 @@ type ProtectionRule struct { RequiredStatusChecksEnforcementLevel *string `json:"required_status_checks_enforcement_level,omitempty"` StrictRequiredStatusChecksPolicy *bool `json:"strict_required_status_checks_policy,omitempty"` SignatureRequirementEnforcementLevel *string `json:"signature_requirement_enforcement_level,omitempty"` - LinearHistoryEnforcementLevel *string `json:"linear_history_requirement_enforcement_level,omitempty"` + LinearHistoryRequirementEnforcementLevel *string `json:"linear_history_requirement_enforcement_level,omitempty"` AdminEnforced bool `json:"admin_enforced"` ForcePushesEnforcementLevel *string `json:"allow_force_pushes_enforcement_level,omitempty"` DeletionsEnforcementLevel *string `json:"allow_deletions_enforcement_level,omitempty"` From 32d38c855fd57b7fd698ccbdc5c1019e53fb2fa0 Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:34:23 -0700 Subject: [PATCH 15/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index c8cc4ab2e80..9b4db25b601 100644 --- a/github/repos.go +++ b/github/repos.go @@ -784,7 +784,7 @@ type ProtectionRule struct { StrictRequiredStatusChecksPolicy *bool `json:"strict_required_status_checks_policy,omitempty"` SignatureRequirementEnforcementLevel *string `json:"signature_requirement_enforcement_level,omitempty"` LinearHistoryRequirementEnforcementLevel *string `json:"linear_history_requirement_enforcement_level,omitempty"` - AdminEnforced bool `json:"admin_enforced"` + AdminEnforced *bool `json:"admin_enforced,omitempty"` ForcePushesEnforcementLevel *string `json:"allow_force_pushes_enforcement_level,omitempty"` DeletionsEnforcementLevel *string `json:"allow_deletions_enforcement_level,omitempty"` MergeQueueEnforcementLevel *string `json:"merge_queue_enforcement_level,omitempty"` From 8885ced949e51b9af7b8119abd906c59a20e8757 Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:34:37 -0700 Subject: [PATCH 16/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index 9b4db25b601..305d8515250 100644 --- a/github/repos.go +++ b/github/repos.go @@ -785,7 +785,7 @@ type ProtectionRule struct { SignatureRequirementEnforcementLevel *string `json:"signature_requirement_enforcement_level,omitempty"` LinearHistoryRequirementEnforcementLevel *string `json:"linear_history_requirement_enforcement_level,omitempty"` AdminEnforced *bool `json:"admin_enforced,omitempty"` - ForcePushesEnforcementLevel *string `json:"allow_force_pushes_enforcement_level,omitempty"` + AllowForcePushesEnforcementLevel *string `json:"allow_force_pushes_enforcement_level,omitempty"` DeletionsEnforcementLevel *string `json:"allow_deletions_enforcement_level,omitempty"` MergeQueueEnforcementLevel *string `json:"merge_queue_enforcement_level,omitempty"` DeploymentEnforcementLevel *string `json:"required_deployments_enforcement_level,omitempty"` From bba5ca43d10b95a8d02fb99477b0ba3cf9a5a39c Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:34:47 -0700 Subject: [PATCH 17/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index 305d8515250..8332be2e448 100644 --- a/github/repos.go +++ b/github/repos.go @@ -786,7 +786,7 @@ type ProtectionRule struct { LinearHistoryRequirementEnforcementLevel *string `json:"linear_history_requirement_enforcement_level,omitempty"` AdminEnforced *bool `json:"admin_enforced,omitempty"` AllowForcePushesEnforcementLevel *string `json:"allow_force_pushes_enforcement_level,omitempty"` - DeletionsEnforcementLevel *string `json:"allow_deletions_enforcement_level,omitempty"` + AllowDeletionsEnforcementLevel *string `json:"allow_deletions_enforcement_level,omitempty"` MergeQueueEnforcementLevel *string `json:"merge_queue_enforcement_level,omitempty"` DeploymentEnforcementLevel *string `json:"required_deployments_enforcement_level,omitempty"` ConversationResolutionLevel *string `json:"required_conversation_resolution_level,omitempty"` From d747c3569b08b457f0fdc022444846f440a6c37a Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:34:58 -0700 Subject: [PATCH 18/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index 8332be2e448..2640e0eafb3 100644 --- a/github/repos.go +++ b/github/repos.go @@ -788,7 +788,7 @@ type ProtectionRule struct { AllowForcePushesEnforcementLevel *string `json:"allow_force_pushes_enforcement_level,omitempty"` AllowDeletionsEnforcementLevel *string `json:"allow_deletions_enforcement_level,omitempty"` MergeQueueEnforcementLevel *string `json:"merge_queue_enforcement_level,omitempty"` - DeploymentEnforcementLevel *string `json:"required_deployments_enforcement_level,omitempty"` + RequiredDeploymentsEnforcementLevel *string `json:"required_deployments_enforcement_level,omitempty"` ConversationResolutionLevel *string `json:"required_conversation_resolution_level,omitempty"` AuthorizedActorsOnly bool `json:"authorized_actors_only"` AuthorizedActorNames []string `json:"authorized_actor_names,omitempty"` From 0b489deb755f3d7d20665adf18e55a448c550307 Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:35:09 -0700 Subject: [PATCH 19/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index 2640e0eafb3..2b745aa27c4 100644 --- a/github/repos.go +++ b/github/repos.go @@ -789,7 +789,7 @@ type ProtectionRule struct { AllowDeletionsEnforcementLevel *string `json:"allow_deletions_enforcement_level,omitempty"` MergeQueueEnforcementLevel *string `json:"merge_queue_enforcement_level,omitempty"` RequiredDeploymentsEnforcementLevel *string `json:"required_deployments_enforcement_level,omitempty"` - ConversationResolutionLevel *string `json:"required_conversation_resolution_level,omitempty"` + RequiredConversationResolutionLevel *string `json:"required_conversation_resolution_level,omitempty"` AuthorizedActorsOnly bool `json:"authorized_actors_only"` AuthorizedActorNames []string `json:"authorized_actor_names,omitempty"` } From 7e2781947c91b7a06e334173d47e1821a13afac0 Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:35:19 -0700 Subject: [PATCH 20/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index 2b745aa27c4..d5a0db65030 100644 --- a/github/repos.go +++ b/github/repos.go @@ -790,7 +790,7 @@ type ProtectionRule struct { MergeQueueEnforcementLevel *string `json:"merge_queue_enforcement_level,omitempty"` RequiredDeploymentsEnforcementLevel *string `json:"required_deployments_enforcement_level,omitempty"` RequiredConversationResolutionLevel *string `json:"required_conversation_resolution_level,omitempty"` - AuthorizedActorsOnly bool `json:"authorized_actors_only"` + AuthorizedActorsOnly *bool `json:"authorized_actors_only,omitempty"` AuthorizedActorNames []string `json:"authorized_actor_names,omitempty"` } From d87438e362749e57abbcaa6950626a052442b4d9 Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:35:34 -0700 Subject: [PATCH 21/23] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index d5a0db65030..b781503f09a 100644 --- a/github/repos.go +++ b/github/repos.go @@ -794,7 +794,7 @@ type ProtectionRule struct { AuthorizedActorNames []string `json:"authorized_actor_names,omitempty"` } -// If the BranchProtection was edited, the changes to the rule +// ProtectionChanges represents the changes to the rule if the BranchProtection was edited. type ProtectionChanges struct { AuthorizedActorsOnly *AuthorizedActorsOnly `json:"authorized_actors_only,omitempty"` AuthorizedActorNames *AuthorizedActorNames `json:"authorized_actor_names,omitempty"` From e6ba6ff2a1ef62da8ab41d2422ecd4dcdd4b8f09 Mon Sep 17 00:00:00 2001 From: Madhura Bhogate Date: Wed, 22 Sep 2021 09:48:37 -0700 Subject: [PATCH 22/23] chore: added docstring, renamed struct --- github/event_types.go | 14 +- github/github-accessors.go | 290 +++++++++++++++---------- github/github-accessors_test.go | 360 ++++++++++++++++++++------------ github/repos.go | 53 ++--- 4 files changed, 450 insertions(+), 267 deletions(-) diff --git a/github/event_types.go b/github/event_types.go index 83a6dd14008..e743e1804bb 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -16,16 +16,16 @@ type RequestedAction struct { } // BranchProtectionEvent triggered when a check suite is "created", "edited", or "deleted". -// The Webhook event name is "branch_protection". +// The Webhook event name is "branch_protection_rule". // // GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#branch_protection_rule type BranchProtectionRuleEvent struct { - Action *string `json:"action,omitempty"` - Rule *ProtectionRules `json:"rule,omitempty"` - Changes *ProtectionChanges `json:"changes,omitempty"` - Repo *Repository `json:"repository,omitempty"` - Org *Organization `json:"organization,omitempty"` - Sender *User `json:"sender,omitempty"` + Action *string `json:"action,omitempty"` + Rule *BranchProtectionRule `json:"rule,omitempty"` + Changes *ProtectionChanges `json:"changes,omitempty"` + Repo *Repository `json:"repository,omitempty"` + Org *Organization `json:"organization,omitempty"` + Sender *User `json:"sender,omitempty"` } // CheckRunEvent is triggered when a check run is "created", "completed", or "rerequested". diff --git a/github/github-accessors.go b/github/github-accessors.go index fbc7af1ed8c..b7925d400b2 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -1188,6 +1188,14 @@ func (a *AuthorizationUpdateRequest) GetNoteURL() string { return *a.NoteURL } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (a *AuthorizedActorsOnly) GetFrom() bool { + if a == nil || a.From == nil { + return false + } + return *a.From +} + // GetID returns the ID field if it's non-nil, zero value otherwise. func (a *Autolink) GetID() int64 { if a == nil || a.ID == nil { @@ -1364,6 +1372,182 @@ func (b *BranchPolicy) GetProtectedBranches() bool { return *b.ProtectedBranches } +// GetAdminEnforced returns the AdminEnforced field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetAdminEnforced() bool { + if b == nil || b.AdminEnforced == nil { + return false + } + return *b.AdminEnforced +} + +// GetAllowDeletionsEnforcementLevel returns the AllowDeletionsEnforcementLevel field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetAllowDeletionsEnforcementLevel() string { + if b == nil || b.AllowDeletionsEnforcementLevel == nil { + return "" + } + return *b.AllowDeletionsEnforcementLevel +} + +// GetAllowForcePushesEnforcementLevel returns the AllowForcePushesEnforcementLevel field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetAllowForcePushesEnforcementLevel() string { + if b == nil || b.AllowForcePushesEnforcementLevel == nil { + return "" + } + return *b.AllowForcePushesEnforcementLevel +} + +// GetAuthorizedActorsOnly returns the AuthorizedActorsOnly field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetAuthorizedActorsOnly() bool { + if b == nil || b.AuthorizedActorsOnly == nil { + return false + } + return *b.AuthorizedActorsOnly +} + +// GetAuthorizedDismissalActorsOnly returns the AuthorizedDismissalActorsOnly field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetAuthorizedDismissalActorsOnly() bool { + if b == nil || b.AuthorizedDismissalActorsOnly == nil { + return false + } + return *b.AuthorizedDismissalActorsOnly +} + +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetCreatedAt() Timestamp { + if b == nil || b.CreatedAt == nil { + return Timestamp{} + } + return *b.CreatedAt +} + +// GetDismissStaleReviewsOnPush returns the DismissStaleReviewsOnPush field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetDismissStaleReviewsOnPush() bool { + if b == nil || b.DismissStaleReviewsOnPush == nil { + return false + } + return *b.DismissStaleReviewsOnPush +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetID() int64 { + if b == nil || b.ID == nil { + return 0 + } + return *b.ID +} + +// GetIgnoreApprovalsFromContributors returns the IgnoreApprovalsFromContributors field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetIgnoreApprovalsFromContributors() bool { + if b == nil || b.IgnoreApprovalsFromContributors == nil { + return false + } + return *b.IgnoreApprovalsFromContributors +} + +// GetLinearHistoryRequirementEnforcementLevel returns the LinearHistoryRequirementEnforcementLevel field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetLinearHistoryRequirementEnforcementLevel() string { + if b == nil || b.LinearHistoryRequirementEnforcementLevel == nil { + return "" + } + return *b.LinearHistoryRequirementEnforcementLevel +} + +// GetMergeQueueEnforcementLevel returns the MergeQueueEnforcementLevel field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetMergeQueueEnforcementLevel() string { + if b == nil || b.MergeQueueEnforcementLevel == nil { + return "" + } + return *b.MergeQueueEnforcementLevel +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetName() string { + if b == nil || b.Name == nil { + return "" + } + return *b.Name +} + +// GetPullRequestReviewsEnforcementLevel returns the PullRequestReviewsEnforcementLevel field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetPullRequestReviewsEnforcementLevel() string { + if b == nil || b.PullRequestReviewsEnforcementLevel == nil { + return "" + } + return *b.PullRequestReviewsEnforcementLevel +} + +// GetRepositoryID returns the RepositoryID field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetRepositoryID() int64 { + if b == nil || b.RepositoryID == nil { + return 0 + } + return *b.RepositoryID +} + +// GetRequireCodeOwnerReview returns the RequireCodeOwnerReview field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetRequireCodeOwnerReview() bool { + if b == nil || b.RequireCodeOwnerReview == nil { + return false + } + return *b.RequireCodeOwnerReview +} + +// GetRequiredApprovingReviewCount returns the RequiredApprovingReviewCount field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetRequiredApprovingReviewCount() int { + if b == nil || b.RequiredApprovingReviewCount == nil { + return 0 + } + return *b.RequiredApprovingReviewCount +} + +// GetRequiredConversationResolutionLevel returns the RequiredConversationResolutionLevel field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetRequiredConversationResolutionLevel() string { + if b == nil || b.RequiredConversationResolutionLevel == nil { + return "" + } + return *b.RequiredConversationResolutionLevel +} + +// GetRequiredDeploymentsEnforcementLevel returns the RequiredDeploymentsEnforcementLevel field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetRequiredDeploymentsEnforcementLevel() string { + if b == nil || b.RequiredDeploymentsEnforcementLevel == nil { + return "" + } + return *b.RequiredDeploymentsEnforcementLevel +} + +// GetRequiredStatusChecksEnforcementLevel returns the RequiredStatusChecksEnforcementLevel field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetRequiredStatusChecksEnforcementLevel() string { + if b == nil || b.RequiredStatusChecksEnforcementLevel == nil { + return "" + } + return *b.RequiredStatusChecksEnforcementLevel +} + +// GetSignatureRequirementEnforcementLevel returns the SignatureRequirementEnforcementLevel field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetSignatureRequirementEnforcementLevel() string { + if b == nil || b.SignatureRequirementEnforcementLevel == nil { + return "" + } + return *b.SignatureRequirementEnforcementLevel +} + +// GetStrictRequiredStatusChecksPolicy returns the StrictRequiredStatusChecksPolicy field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetStrictRequiredStatusChecksPolicy() bool { + if b == nil || b.StrictRequiredStatusChecksPolicy == nil { + return false + } + return *b.StrictRequiredStatusChecksPolicy +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetUpdatedAt() Timestamp { + if b == nil || b.UpdatedAt == nil { + return Timestamp{} + } + return *b.UpdatedAt +} + // GetAction returns the Action field if it's non-nil, zero value otherwise. func (b *BranchProtectionRuleEvent) GetAction() string { if b == nil || b.Action == nil { @@ -1397,7 +1581,7 @@ func (b *BranchProtectionRuleEvent) GetRepo() *Repository { } // GetRule returns the Rule field. -func (b *BranchProtectionRuleEvent) GetRule() *ProtectionRules { +func (b *BranchProtectionRuleEvent) GetRule() *BranchProtectionRule { if b == nil { return nil } @@ -10660,110 +10844,6 @@ func (p *ProtectionRule) GetWaitTimer() int { return *p.WaitTimer } -// GetConversationResolutionLevel returns the ConversationResolutionLevel field if it's non-nil, zero value otherwise. -func (p *ProtectionRules) GetConversationResolutionLevel() string { - if p == nil || p.ConversationResolutionLevel == nil { - return "" - } - return *p.ConversationResolutionLevel -} - -// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. -func (p *ProtectionRules) GetCreatedAt() Timestamp { - if p == nil || p.CreatedAt == nil { - return Timestamp{} - } - return *p.CreatedAt -} - -// GetDeletionsEnforcementLevel returns the DeletionsEnforcementLevel field if it's non-nil, zero value otherwise. -func (p *ProtectionRules) GetDeletionsEnforcementLevel() string { - if p == nil || p.DeletionsEnforcementLevel == nil { - return "" - } - return *p.DeletionsEnforcementLevel -} - -// GetDeploymentEnforcementLevel returns the DeploymentEnforcementLevel field if it's non-nil, zero value otherwise. -func (p *ProtectionRules) GetDeploymentEnforcementLevel() string { - if p == nil || p.DeploymentEnforcementLevel == nil { - return "" - } - return *p.DeploymentEnforcementLevel -} - -// GetForcePushesEnforcementLevel returns the ForcePushesEnforcementLevel field if it's non-nil, zero value otherwise. -func (p *ProtectionRules) GetForcePushesEnforcementLevel() string { - if p == nil || p.ForcePushesEnforcementLevel == nil { - return "" - } - return *p.ForcePushesEnforcementLevel -} - -// GetID returns the ID field if it's non-nil, zero value otherwise. -func (p *ProtectionRules) GetID() int64 { - if p == nil || p.ID == nil { - return 0 - } - return *p.ID -} - -// GetLinearHistoryEnforcementLevel returns the LinearHistoryEnforcementLevel field if it's non-nil, zero value otherwise. -func (p *ProtectionRules) GetLinearHistoryEnforcementLevel() string { - if p == nil || p.LinearHistoryEnforcementLevel == nil { - return "" - } - return *p.LinearHistoryEnforcementLevel -} - -// GetMergeQueueEnforcementLevel returns the MergeQueueEnforcementLevel field if it's non-nil, zero value otherwise. -func (p *ProtectionRules) GetMergeQueueEnforcementLevel() string { - if p == nil || p.MergeQueueEnforcementLevel == nil { - return "" - } - return *p.MergeQueueEnforcementLevel -} - -// GetName returns the Name field if it's non-nil, zero value otherwise. -func (p *ProtectionRules) GetName() string { - if p == nil || p.Name == nil { - return "" - } - return *p.Name -} - -// GetPullRequestReviewsEnforcementLevel returns the PullRequestReviewsEnforcementLevel field if it's non-nil, zero value otherwise. -func (p *ProtectionRules) GetPullRequestReviewsEnforcementLevel() string { - if p == nil || p.PullRequestReviewsEnforcementLevel == nil { - return "" - } - return *p.PullRequestReviewsEnforcementLevel -} - -// GetRepositoryID returns the RepositoryID field if it's non-nil, zero value otherwise. -func (p *ProtectionRules) GetRepositoryID() int64 { - if p == nil || p.RepositoryID == nil { - return 0 - } - return *p.RepositoryID -} - -// GetStatusChecksEnforcementLevel returns the StatusChecksEnforcementLevel field if it's non-nil, zero value otherwise. -func (p *ProtectionRules) GetStatusChecksEnforcementLevel() string { - if p == nil || p.StatusChecksEnforcementLevel == nil { - return "" - } - return *p.StatusChecksEnforcementLevel -} - -// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. -func (p *ProtectionRules) GetUpdatedAt() Timestamp { - if p == nil || p.UpdatedAt == nil { - return Timestamp{} - } - return *p.UpdatedAt -} - // GetInstallation returns the Installation field. func (p *PublicEvent) GetInstallation() *Installation { if p == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 01a18955a2a..e7f2a48da08 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -1417,6 +1417,16 @@ func TestAuthorizationUpdateRequest_GetNoteURL(tt *testing.T) { a.GetNoteURL() } +func TestAuthorizedActorsOnly_GetFrom(tt *testing.T) { + var zeroValue bool + a := &AuthorizedActorsOnly{From: &zeroValue} + a.GetFrom() + a = &AuthorizedActorsOnly{} + a.GetFrom() + a = nil + a.GetFrom() +} + func TestAutolink_GetID(tt *testing.T) { var zeroValue int64 a := &Autolink{ID: &zeroValue} @@ -1631,6 +1641,226 @@ func TestBranchPolicy_GetProtectedBranches(tt *testing.T) { b.GetProtectedBranches() } +func TestBranchProtectionRule_GetAdminEnforced(tt *testing.T) { + var zeroValue bool + b := &BranchProtectionRule{AdminEnforced: &zeroValue} + b.GetAdminEnforced() + b = &BranchProtectionRule{} + b.GetAdminEnforced() + b = nil + b.GetAdminEnforced() +} + +func TestBranchProtectionRule_GetAllowDeletionsEnforcementLevel(tt *testing.T) { + var zeroValue string + b := &BranchProtectionRule{AllowDeletionsEnforcementLevel: &zeroValue} + b.GetAllowDeletionsEnforcementLevel() + b = &BranchProtectionRule{} + b.GetAllowDeletionsEnforcementLevel() + b = nil + b.GetAllowDeletionsEnforcementLevel() +} + +func TestBranchProtectionRule_GetAllowForcePushesEnforcementLevel(tt *testing.T) { + var zeroValue string + b := &BranchProtectionRule{AllowForcePushesEnforcementLevel: &zeroValue} + b.GetAllowForcePushesEnforcementLevel() + b = &BranchProtectionRule{} + b.GetAllowForcePushesEnforcementLevel() + b = nil + b.GetAllowForcePushesEnforcementLevel() +} + +func TestBranchProtectionRule_GetAuthorizedActorsOnly(tt *testing.T) { + var zeroValue bool + b := &BranchProtectionRule{AuthorizedActorsOnly: &zeroValue} + b.GetAuthorizedActorsOnly() + b = &BranchProtectionRule{} + b.GetAuthorizedActorsOnly() + b = nil + b.GetAuthorizedActorsOnly() +} + +func TestBranchProtectionRule_GetAuthorizedDismissalActorsOnly(tt *testing.T) { + var zeroValue bool + b := &BranchProtectionRule{AuthorizedDismissalActorsOnly: &zeroValue} + b.GetAuthorizedDismissalActorsOnly() + b = &BranchProtectionRule{} + b.GetAuthorizedDismissalActorsOnly() + b = nil + b.GetAuthorizedDismissalActorsOnly() +} + +func TestBranchProtectionRule_GetCreatedAt(tt *testing.T) { + var zeroValue Timestamp + b := &BranchProtectionRule{CreatedAt: &zeroValue} + b.GetCreatedAt() + b = &BranchProtectionRule{} + b.GetCreatedAt() + b = nil + b.GetCreatedAt() +} + +func TestBranchProtectionRule_GetDismissStaleReviewsOnPush(tt *testing.T) { + var zeroValue bool + b := &BranchProtectionRule{DismissStaleReviewsOnPush: &zeroValue} + b.GetDismissStaleReviewsOnPush() + b = &BranchProtectionRule{} + b.GetDismissStaleReviewsOnPush() + b = nil + b.GetDismissStaleReviewsOnPush() +} + +func TestBranchProtectionRule_GetID(tt *testing.T) { + var zeroValue int64 + b := &BranchProtectionRule{ID: &zeroValue} + b.GetID() + b = &BranchProtectionRule{} + b.GetID() + b = nil + b.GetID() +} + +func TestBranchProtectionRule_GetIgnoreApprovalsFromContributors(tt *testing.T) { + var zeroValue bool + b := &BranchProtectionRule{IgnoreApprovalsFromContributors: &zeroValue} + b.GetIgnoreApprovalsFromContributors() + b = &BranchProtectionRule{} + b.GetIgnoreApprovalsFromContributors() + b = nil + b.GetIgnoreApprovalsFromContributors() +} + +func TestBranchProtectionRule_GetLinearHistoryRequirementEnforcementLevel(tt *testing.T) { + var zeroValue string + b := &BranchProtectionRule{LinearHistoryRequirementEnforcementLevel: &zeroValue} + b.GetLinearHistoryRequirementEnforcementLevel() + b = &BranchProtectionRule{} + b.GetLinearHistoryRequirementEnforcementLevel() + b = nil + b.GetLinearHistoryRequirementEnforcementLevel() +} + +func TestBranchProtectionRule_GetMergeQueueEnforcementLevel(tt *testing.T) { + var zeroValue string + b := &BranchProtectionRule{MergeQueueEnforcementLevel: &zeroValue} + b.GetMergeQueueEnforcementLevel() + b = &BranchProtectionRule{} + b.GetMergeQueueEnforcementLevel() + b = nil + b.GetMergeQueueEnforcementLevel() +} + +func TestBranchProtectionRule_GetName(tt *testing.T) { + var zeroValue string + b := &BranchProtectionRule{Name: &zeroValue} + b.GetName() + b = &BranchProtectionRule{} + b.GetName() + b = nil + b.GetName() +} + +func TestBranchProtectionRule_GetPullRequestReviewsEnforcementLevel(tt *testing.T) { + var zeroValue string + b := &BranchProtectionRule{PullRequestReviewsEnforcementLevel: &zeroValue} + b.GetPullRequestReviewsEnforcementLevel() + b = &BranchProtectionRule{} + b.GetPullRequestReviewsEnforcementLevel() + b = nil + b.GetPullRequestReviewsEnforcementLevel() +} + +func TestBranchProtectionRule_GetRepositoryID(tt *testing.T) { + var zeroValue int64 + b := &BranchProtectionRule{RepositoryID: &zeroValue} + b.GetRepositoryID() + b = &BranchProtectionRule{} + b.GetRepositoryID() + b = nil + b.GetRepositoryID() +} + +func TestBranchProtectionRule_GetRequireCodeOwnerReview(tt *testing.T) { + var zeroValue bool + b := &BranchProtectionRule{RequireCodeOwnerReview: &zeroValue} + b.GetRequireCodeOwnerReview() + b = &BranchProtectionRule{} + b.GetRequireCodeOwnerReview() + b = nil + b.GetRequireCodeOwnerReview() +} + +func TestBranchProtectionRule_GetRequiredApprovingReviewCount(tt *testing.T) { + var zeroValue int + b := &BranchProtectionRule{RequiredApprovingReviewCount: &zeroValue} + b.GetRequiredApprovingReviewCount() + b = &BranchProtectionRule{} + b.GetRequiredApprovingReviewCount() + b = nil + b.GetRequiredApprovingReviewCount() +} + +func TestBranchProtectionRule_GetRequiredConversationResolutionLevel(tt *testing.T) { + var zeroValue string + b := &BranchProtectionRule{RequiredConversationResolutionLevel: &zeroValue} + b.GetRequiredConversationResolutionLevel() + b = &BranchProtectionRule{} + b.GetRequiredConversationResolutionLevel() + b = nil + b.GetRequiredConversationResolutionLevel() +} + +func TestBranchProtectionRule_GetRequiredDeploymentsEnforcementLevel(tt *testing.T) { + var zeroValue string + b := &BranchProtectionRule{RequiredDeploymentsEnforcementLevel: &zeroValue} + b.GetRequiredDeploymentsEnforcementLevel() + b = &BranchProtectionRule{} + b.GetRequiredDeploymentsEnforcementLevel() + b = nil + b.GetRequiredDeploymentsEnforcementLevel() +} + +func TestBranchProtectionRule_GetRequiredStatusChecksEnforcementLevel(tt *testing.T) { + var zeroValue string + b := &BranchProtectionRule{RequiredStatusChecksEnforcementLevel: &zeroValue} + b.GetRequiredStatusChecksEnforcementLevel() + b = &BranchProtectionRule{} + b.GetRequiredStatusChecksEnforcementLevel() + b = nil + b.GetRequiredStatusChecksEnforcementLevel() +} + +func TestBranchProtectionRule_GetSignatureRequirementEnforcementLevel(tt *testing.T) { + var zeroValue string + b := &BranchProtectionRule{SignatureRequirementEnforcementLevel: &zeroValue} + b.GetSignatureRequirementEnforcementLevel() + b = &BranchProtectionRule{} + b.GetSignatureRequirementEnforcementLevel() + b = nil + b.GetSignatureRequirementEnforcementLevel() +} + +func TestBranchProtectionRule_GetStrictRequiredStatusChecksPolicy(tt *testing.T) { + var zeroValue bool + b := &BranchProtectionRule{StrictRequiredStatusChecksPolicy: &zeroValue} + b.GetStrictRequiredStatusChecksPolicy() + b = &BranchProtectionRule{} + b.GetStrictRequiredStatusChecksPolicy() + b = nil + b.GetStrictRequiredStatusChecksPolicy() +} + +func TestBranchProtectionRule_GetUpdatedAt(tt *testing.T) { + var zeroValue Timestamp + b := &BranchProtectionRule{UpdatedAt: &zeroValue} + b.GetUpdatedAt() + b = &BranchProtectionRule{} + b.GetUpdatedAt() + b = nil + b.GetUpdatedAt() +} + func TestBranchProtectionRuleEvent_GetAction(tt *testing.T) { var zeroValue string b := &BranchProtectionRuleEvent{Action: &zeroValue} @@ -12426,136 +12656,6 @@ func TestProtectionRule_GetWaitTimer(tt *testing.T) { p.GetWaitTimer() } -func TestProtectionRules_GetConversationResolutionLevel(tt *testing.T) { - var zeroValue string - p := &ProtectionRules{ConversationResolutionLevel: &zeroValue} - p.GetConversationResolutionLevel() - p = &ProtectionRules{} - p.GetConversationResolutionLevel() - p = nil - p.GetConversationResolutionLevel() -} - -func TestProtectionRules_GetCreatedAt(tt *testing.T) { - var zeroValue Timestamp - p := &ProtectionRules{CreatedAt: &zeroValue} - p.GetCreatedAt() - p = &ProtectionRules{} - p.GetCreatedAt() - p = nil - p.GetCreatedAt() -} - -func TestProtectionRules_GetDeletionsEnforcementLevel(tt *testing.T) { - var zeroValue string - p := &ProtectionRules{DeletionsEnforcementLevel: &zeroValue} - p.GetDeletionsEnforcementLevel() - p = &ProtectionRules{} - p.GetDeletionsEnforcementLevel() - p = nil - p.GetDeletionsEnforcementLevel() -} - -func TestProtectionRules_GetDeploymentEnforcementLevel(tt *testing.T) { - var zeroValue string - p := &ProtectionRules{DeploymentEnforcementLevel: &zeroValue} - p.GetDeploymentEnforcementLevel() - p = &ProtectionRules{} - p.GetDeploymentEnforcementLevel() - p = nil - p.GetDeploymentEnforcementLevel() -} - -func TestProtectionRules_GetForcePushesEnforcementLevel(tt *testing.T) { - var zeroValue string - p := &ProtectionRules{ForcePushesEnforcementLevel: &zeroValue} - p.GetForcePushesEnforcementLevel() - p = &ProtectionRules{} - p.GetForcePushesEnforcementLevel() - p = nil - p.GetForcePushesEnforcementLevel() -} - -func TestProtectionRules_GetID(tt *testing.T) { - var zeroValue int64 - p := &ProtectionRules{ID: &zeroValue} - p.GetID() - p = &ProtectionRules{} - p.GetID() - p = nil - p.GetID() -} - -func TestProtectionRules_GetLinearHistoryEnforcementLevel(tt *testing.T) { - var zeroValue string - p := &ProtectionRules{LinearHistoryEnforcementLevel: &zeroValue} - p.GetLinearHistoryEnforcementLevel() - p = &ProtectionRules{} - p.GetLinearHistoryEnforcementLevel() - p = nil - p.GetLinearHistoryEnforcementLevel() -} - -func TestProtectionRules_GetMergeQueueEnforcementLevel(tt *testing.T) { - var zeroValue string - p := &ProtectionRules{MergeQueueEnforcementLevel: &zeroValue} - p.GetMergeQueueEnforcementLevel() - p = &ProtectionRules{} - p.GetMergeQueueEnforcementLevel() - p = nil - p.GetMergeQueueEnforcementLevel() -} - -func TestProtectionRules_GetName(tt *testing.T) { - var zeroValue string - p := &ProtectionRules{Name: &zeroValue} - p.GetName() - p = &ProtectionRules{} - p.GetName() - p = nil - p.GetName() -} - -func TestProtectionRules_GetPullRequestReviewsEnforcementLevel(tt *testing.T) { - var zeroValue string - p := &ProtectionRules{PullRequestReviewsEnforcementLevel: &zeroValue} - p.GetPullRequestReviewsEnforcementLevel() - p = &ProtectionRules{} - p.GetPullRequestReviewsEnforcementLevel() - p = nil - p.GetPullRequestReviewsEnforcementLevel() -} - -func TestProtectionRules_GetRepositoryID(tt *testing.T) { - var zeroValue int64 - p := &ProtectionRules{RepositoryID: &zeroValue} - p.GetRepositoryID() - p = &ProtectionRules{} - p.GetRepositoryID() - p = nil - p.GetRepositoryID() -} - -func TestProtectionRules_GetStatusChecksEnforcementLevel(tt *testing.T) { - var zeroValue string - p := &ProtectionRules{StatusChecksEnforcementLevel: &zeroValue} - p.GetStatusChecksEnforcementLevel() - p = &ProtectionRules{} - p.GetStatusChecksEnforcementLevel() - p = nil - p.GetStatusChecksEnforcementLevel() -} - -func TestProtectionRules_GetUpdatedAt(tt *testing.T) { - var zeroValue Timestamp - p := &ProtectionRules{UpdatedAt: &zeroValue} - p.GetUpdatedAt() - p = &ProtectionRules{} - p.GetUpdatedAt() - p = nil - p.GetUpdatedAt() -} - func TestPublicEvent_GetInstallation(tt *testing.T) { p := &PublicEvent{} p.GetInstallation() diff --git a/github/repos.go b/github/repos.go index b781503f09a..f6236b432f7 100644 --- a/github/repos.go +++ b/github/repos.go @@ -767,31 +767,32 @@ type Protection struct { RequiredConversationResolution *RequiredConversationResolution `json:"required_conversation_resolution"` } -type ProtectionRule struct { - ID *int64 `json:"id,omitempty"` - RepositoryID *int64 `json:"repository_id,omitempty"` - Name *string `json:"name,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - UpdatedAt *Timestamp `json:"updated_at,omitempty"` - PullRequestReviewsEnforcementLevel *string `json:"pull_request_reviews_enforcement_level,omitempty"` - RequiredApprovingReviewCount *int `json:"required_approving_review_count,omitempty"` - DismissStaleReviewsOnPush *bool `json:"dismiss_stale_reviews_on_push,omitempty"` - AuthorizedDismissalActorsOnly *bool `json:"authorized_dismissal_actors_only,omitempty"` - IgnoreApprovalsFromContributors *bool `json:"ignore_approvals_from_contributors,omitempty"` - RequireCodeOwnerReview *bool `json:"require_code_owner_review,omitempty"` - RequiredStatusChecks []string `json:"required_status_checks,omitempty"` - RequiredStatusChecksEnforcementLevel *string `json:"required_status_checks_enforcement_level,omitempty"` - StrictRequiredStatusChecksPolicy *bool `json:"strict_required_status_checks_policy,omitempty"` - SignatureRequirementEnforcementLevel *string `json:"signature_requirement_enforcement_level,omitempty"` - LinearHistoryRequirementEnforcementLevel *string `json:"linear_history_requirement_enforcement_level,omitempty"` - AdminEnforced *bool `json:"admin_enforced,omitempty"` - AllowForcePushesEnforcementLevel *string `json:"allow_force_pushes_enforcement_level,omitempty"` - AllowDeletionsEnforcementLevel *string `json:"allow_deletions_enforcement_level,omitempty"` - MergeQueueEnforcementLevel *string `json:"merge_queue_enforcement_level,omitempty"` - RequiredDeploymentsEnforcementLevel *string `json:"required_deployments_enforcement_level,omitempty"` - RequiredConversationResolutionLevel *string `json:"required_conversation_resolution_level,omitempty"` - AuthorizedActorsOnly *bool `json:"authorized_actors_only,omitempty"` - AuthorizedActorNames []string `json:"authorized_actor_names,omitempty"` +// BranchProtectionRule represents the rule applied to a repositories branch. +type BranchProtectionRule struct { + ID *int64 `json:"id,omitempty"` + RepositoryID *int64 `json:"repository_id,omitempty"` + Name *string `json:"name,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + PullRequestReviewsEnforcementLevel *string `json:"pull_request_reviews_enforcement_level,omitempty"` + RequiredApprovingReviewCount *int `json:"required_approving_review_count,omitempty"` + DismissStaleReviewsOnPush *bool `json:"dismiss_stale_reviews_on_push,omitempty"` + AuthorizedDismissalActorsOnly *bool `json:"authorized_dismissal_actors_only,omitempty"` + IgnoreApprovalsFromContributors *bool `json:"ignore_approvals_from_contributors,omitempty"` + RequireCodeOwnerReview *bool `json:"require_code_owner_review,omitempty"` + RequiredStatusChecks []string `json:"required_status_checks,omitempty"` + RequiredStatusChecksEnforcementLevel *string `json:"required_status_checks_enforcement_level,omitempty"` + StrictRequiredStatusChecksPolicy *bool `json:"strict_required_status_checks_policy,omitempty"` + SignatureRequirementEnforcementLevel *string `json:"signature_requirement_enforcement_level,omitempty"` + LinearHistoryRequirementEnforcementLevel *string `json:"linear_history_requirement_enforcement_level,omitempty"` + AdminEnforced *bool `json:"admin_enforced,omitempty"` + AllowForcePushesEnforcementLevel *string `json:"allow_force_pushes_enforcement_level,omitempty"` + AllowDeletionsEnforcementLevel *string `json:"allow_deletions_enforcement_level,omitempty"` + MergeQueueEnforcementLevel *string `json:"merge_queue_enforcement_level,omitempty"` + RequiredDeploymentsEnforcementLevel *string `json:"required_deployments_enforcement_level,omitempty"` + RequiredConversationResolutionLevel *string `json:"required_conversation_resolution_level,omitempty"` + AuthorizedActorsOnly *bool `json:"authorized_actors_only,omitempty"` + AuthorizedActorNames []string `json:"authorized_actor_names,omitempty"` } // ProtectionChanges represents the changes to the rule if the BranchProtection was edited. @@ -800,10 +801,12 @@ type ProtectionChanges struct { AuthorizedActorNames *AuthorizedActorNames `json:"authorized_actor_names,omitempty"` } +// AuthorizedActorNames represents who are authorized to edit the branch protection rules. type AuthorizedActorNames struct { From []string `json:"from,omitempty"` } +// AuthorizedActorsOnly represents if the branche rule can be edited by authorized actors only. type AuthorizedActorsOnly struct { From *bool `json:"from,omitempty"` } From 6883a899da361f63a5ea9943f036517b86aba032 Mon Sep 17 00:00:00 2001 From: Madhura Bhogate <88679717+bhogatemadhura@users.noreply.github.com> Date: Wed, 22 Sep 2021 10:45:02 -0700 Subject: [PATCH 23/23] Update github/event_types.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/event_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/event_types.go b/github/event_types.go index e743e1804bb..9cdbc266876 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -15,7 +15,7 @@ type RequestedAction struct { Identifier string `json:"identifier"` // The integrator reference of the action requested by the user. } -// BranchProtectionEvent triggered when a check suite is "created", "edited", or "deleted". +// BranchProtectionRuleEvent triggered when a check suite is "created", "edited", or "deleted". // The Webhook event name is "branch_protection_rule". // // GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#branch_protection_rule