From 18cd63d0e2bda56f9018d7f85bf11f81e6ce2dd2 Mon Sep 17 00:00:00 2001 From: Jaime Andres Torres B <69700780+XaurDesu@users.noreply.github.com> Date: Mon, 28 Nov 2022 11:58:59 -0500 Subject: [PATCH] Add LockBranch and AllowForkSyncing to repos.go (#2577) Fixes: #2574. --- github/github-accessors.go | 16 ++++++++++++++++ github/github-accessors_test.go | 20 ++++++++++++++++++++ github/repos.go | 4 ++++ 3 files changed, 40 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() diff --git a/github/repos.go b/github/repos.go index 9364e8d69f..2b1a263f0f 100644 --- a/github/repos.go +++ b/github/repos.go @@ -840,6 +840,10 @@ type Protection struct { AllowForcePushes *AllowForcePushes `json:"allow_force_pushes"` 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"` + // 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.