From eb5ae07345445f97caf88819a17771631ab9f808 Mon Sep 17 00:00:00 2001 From: Jasper <62405708+brekelj1@users.noreply.github.com> Date: Mon, 9 Oct 2023 14:06:52 +1100 Subject: [PATCH 1/2] add prevent_self_review on repo environments --- github/github-accessors.go | 16 ++++++++++++++++ github/github-accessors_test.go | 20 ++++++++++++++++++++ github/repos_environments.go | 12 +++++++----- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index a0e7a74366e..a33c1b982a0 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -6934,6 +6934,14 @@ func (e *Environment) GetOwner() string { return *e.Owner } +// GetPreventSelfReview returns the PreventSelfReview field if it's non-nil, zero value otherwise. +func (e *Environment) GetPreventSelfReview() bool { + if e == nil || e.PreventSelfReview == nil { + return false + } + return *e.PreventSelfReview +} + // GetRepo returns the Repo field if it's non-nil, zero value otherwise. func (e *Environment) GetRepo() string { if e == nil || e.Repo == nil { @@ -15534,6 +15542,14 @@ func (p *ProtectionRule) GetNodeID() string { return *p.NodeID } +// GetPreventSelfReview returns the PreventSelfReview field if it's non-nil, zero value otherwise. +func (p *ProtectionRule) GetPreventSelfReview() bool { + if p == nil || p.PreventSelfReview == nil { + return false + } + return *p.PreventSelfReview +} + // GetType returns the Type field if it's non-nil, zero value otherwise. func (p *ProtectionRule) GetType() string { if p == nil || p.Type == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 9b3c36fd9bc..bf497da6e86 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -8128,6 +8128,16 @@ func TestEnvironment_GetOwner(tt *testing.T) { e.GetOwner() } +func TestEnvironment_GetPreventSelfReview(tt *testing.T) { + var zeroValue bool + e := &Environment{PreventSelfReview: &zeroValue} + e.GetPreventSelfReview() + e = &Environment{} + e.GetPreventSelfReview() + e = nil + e.GetPreventSelfReview() +} + func TestEnvironment_GetRepo(tt *testing.T) { var zeroValue string e := &Environment{Repo: &zeroValue} @@ -18047,6 +18057,16 @@ func TestProtectionRule_GetNodeID(tt *testing.T) { p.GetNodeID() } +func TestProtectionRule_GetPreventSelfReview(tt *testing.T) { + var zeroValue bool + p := &ProtectionRule{PreventSelfReview: &zeroValue} + p.GetPreventSelfReview() + p = &ProtectionRule{} + p.GetPreventSelfReview() + p = nil + p.GetPreventSelfReview() +} + func TestProtectionRule_GetType(tt *testing.T) { var zeroValue string p := &ProtectionRule{Type: &zeroValue} diff --git a/github/repos_environments.go b/github/repos_environments.go index 2399a42c746..68f5626b965 100644 --- a/github/repos_environments.go +++ b/github/repos_environments.go @@ -17,6 +17,7 @@ type Environment struct { Owner *string `json:"owner,omitempty"` Repo *string `json:"repo,omitempty"` EnvironmentName *string `json:"environment_name,omitempty"` + PreventSelfReview *bool `json:"prevent_self_review,omitempty"` WaitTimer *int `json:"wait_timer,omitempty"` Reviewers []*EnvReviewers `json:"reviewers,omitempty"` DeploymentBranchPolicy *BranchPolicy `json:"deployment_branch_policy,omitempty"` @@ -52,11 +53,12 @@ type EnvResponse struct { // ProtectionRule represents a single protection rule applied to the environment. type ProtectionRule struct { - ID *int64 `json:"id,omitempty"` - NodeID *string `json:"node_id,omitempty"` - Type *string `json:"type,omitempty"` - WaitTimer *int `json:"wait_timer,omitempty"` - Reviewers []*RequiredReviewer `json:"reviewers,omitempty"` + ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` + PreventSelfReview *bool `json:"prevent_self_review,omitempty"` + Type *string `json:"type,omitempty"` + WaitTimer *int `json:"wait_timer,omitempty"` + Reviewers []*RequiredReviewer `json:"reviewers,omitempty"` } // RequiredReviewer represents a required reviewer. From 516752a1e33c9225a4ee1a41572a5e642c93a228 Mon Sep 17 00:00:00 2001 From: Jasper <62405708+brekelj1@users.noreply.github.com> Date: Tue, 10 Oct 2023 08:28:01 +1100 Subject: [PATCH 2/2] fix: PreventSelfReview on CreateUpdateEnv struct --- github/github-accessors.go | 16 ++++++++-------- github/github-accessors_test.go | 20 ++++++++++---------- github/repos_environments.go | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index a33c1b982a0..78a184e6c80 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -4838,6 +4838,14 @@ func (c *CreateUpdateEnvironment) GetDeploymentBranchPolicy() *BranchPolicy { return c.DeploymentBranchPolicy } +// GetPreventSelfReview returns the PreventSelfReview field if it's non-nil, zero value otherwise. +func (c *CreateUpdateEnvironment) GetPreventSelfReview() bool { + if c == nil || c.PreventSelfReview == nil { + return false + } + return *c.PreventSelfReview +} + // GetWaitTimer returns the WaitTimer field if it's non-nil, zero value otherwise. func (c *CreateUpdateEnvironment) GetWaitTimer() int { if c == nil || c.WaitTimer == nil { @@ -6934,14 +6942,6 @@ func (e *Environment) GetOwner() string { return *e.Owner } -// GetPreventSelfReview returns the PreventSelfReview field if it's non-nil, zero value otherwise. -func (e *Environment) GetPreventSelfReview() bool { - if e == nil || e.PreventSelfReview == nil { - return false - } - return *e.PreventSelfReview -} - // GetRepo returns the Repo field if it's non-nil, zero value otherwise. func (e *Environment) GetRepo() string { if e == nil || e.Repo == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index bf497da6e86..54c89eb9876 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -5712,6 +5712,16 @@ func TestCreateUpdateEnvironment_GetDeploymentBranchPolicy(tt *testing.T) { c.GetDeploymentBranchPolicy() } +func TestCreateUpdateEnvironment_GetPreventSelfReview(tt *testing.T) { + var zeroValue bool + c := &CreateUpdateEnvironment{PreventSelfReview: &zeroValue} + c.GetPreventSelfReview() + c = &CreateUpdateEnvironment{} + c.GetPreventSelfReview() + c = nil + c.GetPreventSelfReview() +} + func TestCreateUpdateEnvironment_GetWaitTimer(tt *testing.T) { var zeroValue int c := &CreateUpdateEnvironment{WaitTimer: &zeroValue} @@ -8128,16 +8138,6 @@ func TestEnvironment_GetOwner(tt *testing.T) { e.GetOwner() } -func TestEnvironment_GetPreventSelfReview(tt *testing.T) { - var zeroValue bool - e := &Environment{PreventSelfReview: &zeroValue} - e.GetPreventSelfReview() - e = &Environment{} - e.GetPreventSelfReview() - e = nil - e.GetPreventSelfReview() -} - func TestEnvironment_GetRepo(tt *testing.T) { var zeroValue string e := &Environment{Repo: &zeroValue} diff --git a/github/repos_environments.go b/github/repos_environments.go index 68f5626b965..e22ca5cd1be 100644 --- a/github/repos_environments.go +++ b/github/repos_environments.go @@ -17,7 +17,6 @@ type Environment struct { Owner *string `json:"owner,omitempty"` Repo *string `json:"repo,omitempty"` EnvironmentName *string `json:"environment_name,omitempty"` - PreventSelfReview *bool `json:"prevent_self_review,omitempty"` WaitTimer *int `json:"wait_timer,omitempty"` Reviewers []*EnvReviewers `json:"reviewers,omitempty"` DeploymentBranchPolicy *BranchPolicy `json:"deployment_branch_policy,omitempty"` @@ -175,6 +174,7 @@ type CreateUpdateEnvironment struct { Reviewers []*EnvReviewers `json:"reviewers"` CanAdminsBypass *bool `json:"can_admins_bypass"` DeploymentBranchPolicy *BranchPolicy `json:"deployment_branch_policy"` + PreventSelfReview *bool `json:"prevent_self_review,omitempty"` } // createUpdateEnvironmentNoEnterprise represents the fields accepted for Pro/Teams private repos.