From 306d4d7af6771137f16d41973e456bc141a40024 Mon Sep 17 00:00:00 2001 From: "richard.de.vries" Date: Wed, 1 Sep 2021 20:25:43 +0200 Subject: [PATCH 1/4] Introduce the auto merge property --- github/repos.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/github/repos.go b/github/repos.go index eaadbb43753..aab18d4d459 100644 --- a/github/repos.go +++ b/github/repos.go @@ -60,6 +60,7 @@ type Repository struct { AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"` AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"` AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"` + AllowAutoMerge *bool `json:"allow_auto_merge,omitempty"` DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"` Topics []string `json:"topics,omitempty"` Archived *bool `json:"archived,omitempty"` @@ -320,6 +321,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"` + AllowAutoMerge *bool `json:"allow_auto_merge,omitempty"` DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"` } @@ -362,6 +364,7 @@ func (s *RepositoriesService) Create(ctx context.Context, org string, repo *Repo AllowSquashMerge: repo.AllowSquashMerge, AllowMergeCommit: repo.AllowMergeCommit, AllowRebaseMerge: repo.AllowRebaseMerge, + AllowAutoMerge: repo.AllowAutoMerge, DeleteBranchOnMerge: repo.DeleteBranchOnMerge, } From 1e5c74a2c450ac31009df06199f148ff3000d79b Mon Sep 17 00:00:00 2001 From: "richard.de.vries" Date: Wed, 1 Sep 2021 20:57:56 +0200 Subject: [PATCH 2/4] Add value accessor with test and add stingify test --- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ github/github-stringify_test.go | 1 + 3 files changed, 19 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index bd94ba944c2..800046d16b6 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -12588,6 +12588,14 @@ func (r *Repository) GetAllowSquashMerge() bool { return *r.AllowSquashMerge } +// GetAllowAutoMerge returns the AllowAutoMerge field if it's non-nil, zero value otherwise. +func (r *Repository) GetAllowAutoMerge() bool { + if r == nil || r.AllowAutoMerge == nil { + return false + } + return *r.AllowAutoMerge +} + // 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 4264ce8b9ad..2283d8a4fdd 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -14671,6 +14671,16 @@ func TestRepository_GetAllowSquashMerge(tt *testing.T) { r.GetAllowSquashMerge() } +func TestRepository_GetAllowAutoMerge(tt *testing.T) { + var zeroValue bool + r := &Repository{AllowAutoMerge: &zeroValue} + r.GetAllowAutoMerge() + r = &Repository{} + r.GetAllowAutoMerge() + r = nil + r.GetAllowAutoMerge() +} + 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 f56d7d4d206..7fae0d70b6c 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -1422,6 +1422,7 @@ func TestRepository_String(t *testing.T) { AllowRebaseMerge: Bool(false), AllowSquashMerge: Bool(false), AllowMergeCommit: Bool(false), + AllowAutoMerge: Bool(false), DeleteBranchOnMerge: Bool(false), Archived: Bool(false), Disabled: Bool(false), From 991a0d5c6fb5155d1cf274d7ad7133482f3e0877 Mon Sep 17 00:00:00 2001 From: "richard.de.vries" Date: Wed, 1 Sep 2021 21:10:25 +0200 Subject: [PATCH 3/4] Fix the stringify test --- github/github-stringify_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index 7fae0d70b6c..f3cab123790 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -1476,7 +1476,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, 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:"", 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, AllowSquashMerge:false, AllowMergeCommit:false, AllowAutoMerge: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:"", 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) } From 8c497d9ad993ff414ed7f89661362848eec56b15 Mon Sep 17 00:00:00 2001 From: "richard.de.vries" Date: Wed, 1 Sep 2021 21:31:22 +0200 Subject: [PATCH 4/4] Remove the auto generate files --- github/github-accessors.go | 16 ++++++++-------- github/github-accessors_test.go | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 800046d16b6..790d185b318 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -12564,6 +12564,14 @@ func (r *RepositoriesSearchResult) GetTotal() int { return *r.Total } +// GetAllowAutoMerge returns the AllowAutoMerge field if it's non-nil, zero value otherwise. +func (r *Repository) GetAllowAutoMerge() bool { + if r == nil || r.AllowAutoMerge == nil { + return false + } + return *r.AllowAutoMerge +} + // GetAllowMergeCommit returns the AllowMergeCommit field if it's non-nil, zero value otherwise. func (r *Repository) GetAllowMergeCommit() bool { if r == nil || r.AllowMergeCommit == nil { @@ -12588,14 +12596,6 @@ func (r *Repository) GetAllowSquashMerge() bool { return *r.AllowSquashMerge } -// GetAllowAutoMerge returns the AllowAutoMerge field if it's non-nil, zero value otherwise. -func (r *Repository) GetAllowAutoMerge() bool { - if r == nil || r.AllowAutoMerge == nil { - return false - } - return *r.AllowAutoMerge -} - // 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 2283d8a4fdd..92a22c7ad11 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -14641,6 +14641,16 @@ func TestRepositoriesSearchResult_GetTotal(tt *testing.T) { r.GetTotal() } +func TestRepository_GetAllowAutoMerge(tt *testing.T) { + var zeroValue bool + r := &Repository{AllowAutoMerge: &zeroValue} + r.GetAllowAutoMerge() + r = &Repository{} + r.GetAllowAutoMerge() + r = nil + r.GetAllowAutoMerge() +} + func TestRepository_GetAllowMergeCommit(tt *testing.T) { var zeroValue bool r := &Repository{AllowMergeCommit: &zeroValue} @@ -14671,16 +14681,6 @@ func TestRepository_GetAllowSquashMerge(tt *testing.T) { r.GetAllowSquashMerge() } -func TestRepository_GetAllowAutoMerge(tt *testing.T) { - var zeroValue bool - r := &Repository{AllowAutoMerge: &zeroValue} - r.GetAllowAutoMerge() - r = &Repository{} - r.GetAllowAutoMerge() - r = nil - r.GetAllowAutoMerge() -} - func TestRepository_GetArchived(tt *testing.T) { var zeroValue bool r := &Repository{Archived: &zeroValue}