From ffeda757fde3c1cec13bb0e75849153196530e8f Mon Sep 17 00:00:00 2001 From: Jaime Andres Torres B <69700780+XaurDesu@users.noreply.github.com> Date: Sat, 26 Nov 2022 00:29:34 -0500 Subject: [PATCH 1/4] Add LockBranch and AllowForkSyncing to repos.go --- github/repos.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/github/repos.go b/github/repos.go index 9364e8d69f..06d444b9ba 100644 --- a/github/repos.go +++ b/github/repos.go @@ -840,6 +840,8 @@ type Protection struct { AllowForcePushes *AllowForcePushes `json:"allow_force_pushes"` AllowDeletions *AllowDeletions `json:"allow_deletions"` RequiredConversationResolution *RequiredConversationResolution `json:"required_conversation_resolution"` + LockBranch *LockBranch `json:"lock_branch"` + AllowForkSyncing *AllowForkSyncing `json:"allow_fork_syncing"` } // BranchProtectionRule represents the rule applied to a repositories branch. @@ -894,11 +896,21 @@ type AdminEnforcedChanges struct { From *bool `json:"from,omitempty"` } +// LockBranch represents if the branch is marked as read-only. If this is true, users will not be able to push to the branch. +type LockBranch struct { + From *bool `json:"lock_branch"` +} + // AllowDeletionsEnforcementLevelChanges represents the changes made to the AllowDeletionsEnforcementLevel policy. type AllowDeletionsEnforcementLevelChanges struct { From *string `json:"from,omitempty"` } +// AllowForkSyncing represents whether users can pull changes from upstream when the branch is locked. +type AllowForkSyncing struct { + From *bool `json:"allow_fork_syncing"` +} + // AuthorizedActorNames represents who are authorized to edit the branch protection rules. type AuthorizedActorNames struct { From []string `json:"from,omitempty"` From 386bb55162239ff8e81bff5271a0ad9f82017a89 Mon Sep 17 00:00:00 2001 From: Jaime Andres Torres B <69700780+XaurDesu@users.noreply.github.com> Date: Sat, 26 Nov 2022 20:11:16 -0500 Subject: [PATCH 2/4] Change github/repos.go json Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/github/repos.go b/github/repos.go index 06d444b9ba..5ad2b45477 100644 --- a/github/repos.go +++ b/github/repos.go @@ -840,8 +840,10 @@ type Protection struct { AllowForcePushes *AllowForcePushes `json:"allow_force_pushes"` AllowDeletions *AllowDeletions `json:"allow_deletions"` RequiredConversationResolution *RequiredConversationResolution `json:"required_conversation_resolution"` - LockBranch *LockBranch `json:"lock_branch"` - AllowForkSyncing *AllowForkSyncing `json:"allow_fork_syncing"` + // LockBranch represents if the branch is marked as read-only. If this is true, users will not be able to push to the branch. + LockBranch *bool `json:"lock_branch,omitempty"` + // AllowForkSyncing represents whether users can pull changes from upstream when the branch is locked. + AllowForkSyncing *bool `json:"allow_fork_syncing,omitempty"` } // BranchProtectionRule represents the rule applied to a repositories branch. From fd728c77de5cdd78737504fef48e93f58de86f72 Mon Sep 17 00:00:00 2001 From: Jaime Andres Torres B <69700780+XaurDesu@users.noreply.github.com> Date: Sat, 26 Nov 2022 20:14:31 -0500 Subject: [PATCH 3/4] Delete LockBranch and AllowForkSyncing struct --- github/repos.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/github/repos.go b/github/repos.go index 5ad2b45477..2b1a263f0f 100644 --- a/github/repos.go +++ b/github/repos.go @@ -841,9 +841,9 @@ type Protection struct { AllowDeletions *AllowDeletions `json:"allow_deletions"` RequiredConversationResolution *RequiredConversationResolution `json:"required_conversation_resolution"` // LockBranch represents if the branch is marked as read-only. If this is true, users will not be able to push to the branch. - LockBranch *bool `json:"lock_branch,omitempty"` + LockBranch *bool `json:"lock_branch,omitempty"` // AllowForkSyncing represents whether users can pull changes from upstream when the branch is locked. - AllowForkSyncing *bool `json:"allow_fork_syncing,omitempty"` + AllowForkSyncing *bool `json:"allow_fork_syncing,omitempty"` } // BranchProtectionRule represents the rule applied to a repositories branch. @@ -898,21 +898,11 @@ type AdminEnforcedChanges struct { From *bool `json:"from,omitempty"` } -// LockBranch represents if the branch is marked as read-only. If this is true, users will not be able to push to the branch. -type LockBranch struct { - From *bool `json:"lock_branch"` -} - // AllowDeletionsEnforcementLevelChanges represents the changes made to the AllowDeletionsEnforcementLevel policy. type AllowDeletionsEnforcementLevelChanges struct { From *string `json:"from,omitempty"` } -// AllowForkSyncing represents whether users can pull changes from upstream when the branch is locked. -type AllowForkSyncing struct { - From *bool `json:"allow_fork_syncing"` -} - // AuthorizedActorNames represents who are authorized to edit the branch protection rules. type AuthorizedActorNames struct { From []string `json:"from,omitempty"` From bc17062663b080f746d51b66243388521ecb00b7 Mon Sep 17 00:00:00 2001 From: Jaime Andres Torres Bermejo Date: Mon, 28 Nov 2022 11:04:04 -0500 Subject: [PATCH 4/4] add generated files from go generate -x ./... --- github/github-accessors.go | 16 ++++++++++++++++ github/github-accessors_test.go | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index 2cc8ce0d56..33de4b7e6a 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -12254,6 +12254,14 @@ func (p *Protection) GetAllowForcePushes() *AllowForcePushes { return p.AllowForcePushes } +// GetAllowForkSyncing returns the AllowForkSyncing field if it's non-nil, zero value otherwise. +func (p *Protection) GetAllowForkSyncing() bool { + if p == nil || p.AllowForkSyncing == nil { + return false + } + return *p.AllowForkSyncing +} + // GetEnforceAdmins returns the EnforceAdmins field. func (p *Protection) GetEnforceAdmins() *AdminEnforcement { if p == nil { @@ -12262,6 +12270,14 @@ func (p *Protection) GetEnforceAdmins() *AdminEnforcement { return p.EnforceAdmins } +// GetLockBranch returns the LockBranch field if it's non-nil, zero value otherwise. +func (p *Protection) GetLockBranch() bool { + if p == nil || p.LockBranch == nil { + return false + } + return *p.LockBranch +} + // GetRequiredConversationResolution returns the RequiredConversationResolution field. func (p *Protection) GetRequiredConversationResolution() *RequiredConversationResolution { if p == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index c056572596..ecc0d7611b 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -14310,6 +14310,16 @@ func TestProtection_GetAllowForcePushes(tt *testing.T) { p.GetAllowForcePushes() } +func TestProtection_GetAllowForkSyncing(tt *testing.T) { + var zeroValue bool + p := &Protection{AllowForkSyncing: &zeroValue} + p.GetAllowForkSyncing() + p = &Protection{} + p.GetAllowForkSyncing() + p = nil + p.GetAllowForkSyncing() +} + func TestProtection_GetEnforceAdmins(tt *testing.T) { p := &Protection{} p.GetEnforceAdmins() @@ -14317,6 +14327,16 @@ func TestProtection_GetEnforceAdmins(tt *testing.T) { p.GetEnforceAdmins() } +func TestProtection_GetLockBranch(tt *testing.T) { + var zeroValue bool + p := &Protection{LockBranch: &zeroValue} + p.GetLockBranch() + p = &Protection{} + p.GetLockBranch() + p = nil + p.GetLockBranch() +} + func TestProtection_GetRequiredConversationResolution(tt *testing.T) { p := &Protection{} p.GetRequiredConversationResolution()