From 823daca2993faa785704e5dc5bf849696ab11cab Mon Sep 17 00:00:00 2001 From: Mark Rosemaker <48681726+MarkRosemaker@users.noreply.github.com> Date: Sat, 5 Mar 2022 20:29:38 +0100 Subject: [PATCH 1/4] add AllowUpdateBranch --- github/repos.go | 1 + 1 file changed, 1 insertion(+) diff --git a/github/repos.go b/github/repos.go index 2b1139b679..e68e1831ce 100644 --- a/github/repos.go +++ b/github/repos.go @@ -363,6 +363,7 @@ type createRepoRequest struct { AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"` AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"` AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"` + AllowUpdateBranch *bool `json:"allow_update_branch,omitempty"` AllowAutoMerge *bool `json:"allow_auto_merge,omitempty"` AllowForking *bool `json:"allow_forking,omitempty"` DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"` From b9225c6c87895036e3475b7032f8cc61435bdfe6 Mon Sep 17 00:00:00 2001 From: Mark Rosemaker <48681726+MarkRosemaker@users.noreply.github.com> Date: Sat, 5 Mar 2022 21:05:59 +0100 Subject: [PATCH 2/4] add to createRepoRequest as well --- github/repos.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/github/repos.go b/github/repos.go index e68e1831ce..b1ce079691 100644 --- a/github/repos.go +++ b/github/repos.go @@ -63,6 +63,7 @@ type Repository struct { Organization *Organization `json:"organization,omitempty"` Permissions map[string]bool `json:"permissions,omitempty"` AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"` + AllowUpdateBranch *bool `json:"allow_update_branch,omitempty"` AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"` AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"` AllowAutoMerge *bool `json:"allow_auto_merge,omitempty"` @@ -408,6 +409,7 @@ func (s *RepositoriesService) Create(ctx context.Context, org string, repo *Repo AllowSquashMerge: repo.AllowSquashMerge, AllowMergeCommit: repo.AllowMergeCommit, AllowRebaseMerge: repo.AllowRebaseMerge, + AllowUpdateBranch: repo.AllowUpdateBranch, AllowAutoMerge: repo.AllowAutoMerge, AllowForking: repo.AllowForking, DeleteBranchOnMerge: repo.DeleteBranchOnMerge, From c4b81da06080d273dfc152b2080f86ab918ab14d Mon Sep 17 00:00:00 2001 From: Mark Rosemaker <48681726+MarkRosemaker@users.noreply.github.com> Date: Sat, 5 Mar 2022 21:06:19 +0100 Subject: [PATCH 3/4] add accessor --- github/github-accessors.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index c87c251f7b..76f4b435f0 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -13836,6 +13836,14 @@ func (r *Repository) GetAllowRebaseMerge() bool { return *r.AllowRebaseMerge } +// GetAllowUpdateBranch returns the AllowUpdateBranch field if it's non-nil, zero value otherwise. +func (r *Repository) GetAllowUpdateBranch() bool { + if r == nil || r.AllowUpdateBranch == nil { + return false + } + return *r.AllowUpdateBranch +} + // GetAllowSquashMerge returns the AllowSquashMerge field if it's non-nil, zero value otherwise. func (r *Repository) GetAllowSquashMerge() bool { if r == nil || r.AllowSquashMerge == nil { From ecb6ec953ad3702e5434a4079e38c0e0c3d6c931 Mon Sep 17 00:00:00 2001 From: Mark Rosemaker <48681726+MarkRosemaker@users.noreply.github.com> Date: Tue, 15 Mar 2022 12:21:08 +0100 Subject: [PATCH 4/4] run go generate --- github/github-accessors.go | 16 ++++++++-------- github/github-accessors_test.go | 10 ++++++++++ github/github-stringify_test.go | 3 ++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 76f4b435f0..ce5fa26ad6 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -13836,14 +13836,6 @@ func (r *Repository) GetAllowRebaseMerge() bool { return *r.AllowRebaseMerge } -// GetAllowUpdateBranch returns the AllowUpdateBranch field if it's non-nil, zero value otherwise. -func (r *Repository) GetAllowUpdateBranch() bool { - if r == nil || r.AllowUpdateBranch == nil { - return false - } - return *r.AllowUpdateBranch -} - // GetAllowSquashMerge returns the AllowSquashMerge field if it's non-nil, zero value otherwise. func (r *Repository) GetAllowSquashMerge() bool { if r == nil || r.AllowSquashMerge == nil { @@ -13852,6 +13844,14 @@ func (r *Repository) GetAllowSquashMerge() bool { return *r.AllowSquashMerge } +// GetAllowUpdateBranch returns the AllowUpdateBranch field if it's non-nil, zero value otherwise. +func (r *Repository) GetAllowUpdateBranch() bool { + if r == nil || r.AllowUpdateBranch == nil { + return false + } + return *r.AllowUpdateBranch +} + // GetArchived returns the Archived field if it's non-nil, zero value otherwise. func (r *Repository) GetArchived() bool { if r == nil || r.Archived == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 1b0556fd4d..f0ce54ecea 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -16130,6 +16130,16 @@ func TestRepository_GetAllowSquashMerge(tt *testing.T) { r.GetAllowSquashMerge() } +func TestRepository_GetAllowUpdateBranch(tt *testing.T) { + var zeroValue bool + r := &Repository{AllowUpdateBranch: &zeroValue} + r.GetAllowUpdateBranch() + r = &Repository{} + r.GetAllowUpdateBranch() + r = nil + r.GetAllowUpdateBranch() +} + func TestRepository_GetArchived(tt *testing.T) { var zeroValue bool r := &Repository{Archived: &zeroValue} diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index 9cb15b8d46..c5bbca9d9e 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -1452,6 +1452,7 @@ func TestRepository_String(t *testing.T) { TemplateRepository: &Repository{}, Organization: &Organization{}, AllowRebaseMerge: Bool(false), + AllowUpdateBranch: Bool(false), AllowSquashMerge: Bool(false), AllowMergeCommit: Bool(false), AllowAutoMerge: Bool(false), @@ -1510,7 +1511,7 @@ func TestRepository_String(t *testing.T) { TeamsURL: String(""), Visibility: String(""), } - want := `github.Repository{ID:0, NodeID:"", Owner:github.User{}, Name:"", FullName:"", Description:"", Homepage:"", CodeOfConduct:github.CodeOfConduct{}, DefaultBranch:"", MasterBranch:"", CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, PushedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, HTMLURL:"", CloneURL:"", GitURL:"", MirrorURL:"", SSHURL:"", SVNURL:"", Language:"", Fork:false, ForksCount:0, NetworkCount:0, OpenIssuesCount:0, OpenIssues:0, StargazersCount:0, SubscribersCount:0, WatchersCount:0, Watchers:0, Size:0, AutoInit:false, Parent:github.Repository{}, Source:github.Repository{}, TemplateRepository:github.Repository{}, Organization:github.Organization{}, AllowRebaseMerge:false, AllowSquashMerge:false, AllowMergeCommit:false, AllowAutoMerge:false, AllowForking:false, DeleteBranchOnMerge:false, Archived:false, Disabled:false, License:github.License{}, Private:false, HasIssues:false, HasWiki:false, HasPages:false, HasProjects:false, HasDownloads:false, IsTemplate:false, LicenseTemplate:"", GitignoreTemplate:"", SecurityAndAnalysis:github.SecurityAndAnalysis{}, TeamID:0, URL:"", ArchiveURL:"", AssigneesURL:"", BlobsURL:"", BranchesURL:"", CollaboratorsURL:"", CommentsURL:"", CommitsURL:"", CompareURL:"", ContentsURL:"", ContributorsURL:"", DeploymentsURL:"", DownloadsURL:"", EventsURL:"", ForksURL:"", GitCommitsURL:"", GitRefsURL:"", GitTagsURL:"", HooksURL:"", IssueCommentURL:"", IssueEventsURL:"", IssuesURL:"", KeysURL:"", LabelsURL:"", LanguagesURL:"", MergesURL:"", MilestonesURL:"", NotificationsURL:"", PullsURL:"", ReleasesURL:"", StargazersURL:"", StatusesURL:"", SubscribersURL:"", SubscriptionURL:"", TagsURL:"", TreesURL:"", TeamsURL:"", Visibility:""}` + want := `github.Repository{ID:0, NodeID:"", Owner:github.User{}, Name:"", FullName:"", Description:"", Homepage:"", CodeOfConduct:github.CodeOfConduct{}, DefaultBranch:"", MasterBranch:"", CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, PushedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, HTMLURL:"", CloneURL:"", GitURL:"", MirrorURL:"", SSHURL:"", SVNURL:"", Language:"", Fork:false, ForksCount:0, NetworkCount:0, OpenIssuesCount:0, OpenIssues:0, StargazersCount:0, SubscribersCount:0, WatchersCount:0, Watchers:0, Size:0, AutoInit:false, Parent:github.Repository{}, Source:github.Repository{}, TemplateRepository:github.Repository{}, Organization:github.Organization{}, AllowRebaseMerge:false, AllowUpdateBranch:false, AllowSquashMerge:false, AllowMergeCommit:false, AllowAutoMerge:false, AllowForking:false, DeleteBranchOnMerge:false, Archived:false, Disabled:false, License:github.License{}, Private:false, HasIssues:false, HasWiki:false, HasPages:false, HasProjects:false, HasDownloads:false, IsTemplate:false, LicenseTemplate:"", GitignoreTemplate:"", SecurityAndAnalysis:github.SecurityAndAnalysis{}, TeamID:0, URL:"", ArchiveURL:"", AssigneesURL:"", BlobsURL:"", BranchesURL:"", CollaboratorsURL:"", CommentsURL:"", CommitsURL:"", CompareURL:"", ContentsURL:"", ContributorsURL:"", DeploymentsURL:"", DownloadsURL:"", EventsURL:"", ForksURL:"", GitCommitsURL:"", GitRefsURL:"", GitTagsURL:"", HooksURL:"", IssueCommentURL:"", IssueEventsURL:"", IssuesURL:"", KeysURL:"", LabelsURL:"", LanguagesURL:"", MergesURL:"", MilestonesURL:"", NotificationsURL:"", PullsURL:"", ReleasesURL:"", StargazersURL:"", StatusesURL:"", SubscribersURL:"", SubscriptionURL:"", TagsURL:"", TreesURL:"", TeamsURL:"", Visibility:""}` if got := v.String(); got != want { t.Errorf("Repository.String = %v, want %v", got, want) }