From 6a76b3398cbd817288cbdf91d7ee52ce7dc476ad Mon Sep 17 00:00:00 2001 From: Casey Date: Tue, 21 Nov 2023 13:25:54 -0800 Subject: [PATCH 1/4] Add default branch edit to repository edit event --- github/event_types.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/github/event_types.go b/github/event_types.go index 6ff1eb84851..327fc561662 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -388,11 +388,12 @@ type GollumEvent struct { // EditChange represents the changes when an issue, pull request, comment, // or repository has been edited. type EditChange struct { - Title *EditTitle `json:"title,omitempty"` - Body *EditBody `json:"body,omitempty"` - Base *EditBase `json:"base,omitempty"` - Repo *EditRepo `json:"repository,omitempty"` - Owner *EditOwner `json:"owner,omitempty"` + Title *EditTitle `json:"title,omitempty"` + Body *EditBody `json:"body,omitempty"` + Base *EditBase `json:"base,omitempty"` + Repo *EditRepo `json:"repository,omitempty"` + Owner *EditOwner `json:"owner,omitempty"` + DefaultBranch *EditDefaultBranch `json:"default_branch,omitempty"` } // EditTitle represents a pull-request title change. @@ -442,6 +443,11 @@ type EditSHA struct { From *string `json:"from,omitempty"` } +// EditDefaultBranch represents a change of repository's default branch name. +type EditDefaultBranch struct { + From *string `json:"from,omitempty"` +} + // ProjectChange represents the changes when a project has been edited. type ProjectChange struct { Name *ProjectName `json:"name,omitempty"` From c685477e7102cf18ab7d72cb62fd5c112cd0a9aa Mon Sep 17 00:00:00 2001 From: Casey Date: Tue, 21 Nov 2023 17:46:01 -0800 Subject: [PATCH 2/4] Add accessors --- github/github-accessors.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index 536ce5a8407..f20ccead86d 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -6678,6 +6678,14 @@ func (e *EditChange) GetBody() *EditBody { return e.Body } +// GetDefaultBranch returns the DefaultBranch field. +func (e *EditChange) GetDefaultBranch() *EditDefaultBranch { + if e == nil { + return nil + } + return e.DefaultBranch +} + // GetOwner returns the Owner field. func (e *EditChange) GetOwner() *EditOwner { if e == nil { @@ -6702,6 +6710,14 @@ func (e *EditChange) GetTitle() *EditTitle { return e.Title } +// GetFrom returns the From field. +func (e *EditDefaultBranch) GetFrom() *string { + if e == nil { + return nil + } + return e.From +} + // GetOwnerInfo returns the OwnerInfo field. func (e *EditOwner) GetOwnerInfo() *OwnerInfo { if e == nil { From da4be86acdd791a534fac1c8694d761609d3f1b6 Mon Sep 17 00:00:00 2001 From: Casey Date: Tue, 21 Nov 2023 17:57:24 -0800 Subject: [PATCH 3/4] Update github-accessors.go --- github/github-accessors.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index f20ccead86d..9998d989437 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -6711,11 +6711,11 @@ func (e *EditChange) GetTitle() *EditTitle { } // GetFrom returns the From field. -func (e *EditDefaultBranch) GetFrom() *string { - if e == nil { - return nil +func (e *EditDefaultBranch) GetFrom() string { + if e == nil || e.From == nil { + return "" } - return e.From + return *e.From } // GetOwnerInfo returns the OwnerInfo field. From c77e71046e7b0861618dee6aa93d92913d7b3b74 Mon Sep 17 00:00:00 2001 From: Casey Duquette Date: Wed, 22 Nov 2023 11:05:42 -0800 Subject: [PATCH 4/4] wip --- github/github-accessors.go | 2 +- github/github-accessors_test.go | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 9998d989437..541be64a8de 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -6710,7 +6710,7 @@ func (e *EditChange) GetTitle() *EditTitle { return e.Title } -// GetFrom returns the From field. +// GetFrom returns the From field if it's non-nil, zero value otherwise. func (e *EditDefaultBranch) GetFrom() string { if e == nil || e.From == nil { return "" diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index abe96ecf98f..49ed8eee086 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -7826,6 +7826,13 @@ func TestEditChange_GetBody(tt *testing.T) { e.GetBody() } +func TestEditChange_GetDefaultBranch(tt *testing.T) { + e := &EditChange{} + e.GetDefaultBranch() + e = nil + e.GetDefaultBranch() +} + func TestEditChange_GetOwner(tt *testing.T) { e := &EditChange{} e.GetOwner() @@ -7847,6 +7854,16 @@ func TestEditChange_GetTitle(tt *testing.T) { e.GetTitle() } +func TestEditDefaultBranch_GetFrom(tt *testing.T) { + var zeroValue string + e := &EditDefaultBranch{From: &zeroValue} + e.GetFrom() + e = &EditDefaultBranch{} + e.GetFrom() + e = nil + e.GetFrom() +} + func TestEditOwner_GetOwnerInfo(tt *testing.T) { e := &EditOwner{} e.GetOwnerInfo()