From 736bd7a156b2eb7c7ff0fe9d6d5355d261f46c01 Mon Sep 17 00:00:00 2001 From: riaje Date: Wed, 24 Jan 2024 17:01:31 -0500 Subject: [PATCH 1/3] Add Topics to EditChange struct --- github/event_types.go | 6 ++++++ github/event_types_test.go | 9 +++++++++ github/github-accessors.go | 16 ++++++++++++++++ github/github-accessors_test.go | 17 +++++++++++++++++ 4 files changed, 48 insertions(+) diff --git a/github/event_types.go b/github/event_types.go index db7c7c69efe..e4a3a521e66 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -394,6 +394,7 @@ type EditChange struct { Repo *EditRepo `json:"repository,omitempty"` Owner *EditOwner `json:"owner,omitempty"` DefaultBranch *EditDefaultBranch `json:"default_branch,omitempty"` + Topics *EditTopics `json:"topics,omitempty"` } // EditTitle represents a pull-request title change. @@ -438,6 +439,11 @@ type RepoName struct { From *string `json:"from,omitempty"` } +// EditTopics represents a change of repository topics. +type EditTopics struct { + From *[]string `json:"from,omitempty"` +} + // EditSHA represents a sha change of a pull-request. type EditSHA struct { From *string `json:"from,omitempty"` diff --git a/github/event_types_test.go b/github/event_types_test.go index 80eca61d0fc..5322f8873f9 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -91,6 +91,9 @@ func TestEditChange_Marshal_Repo(t *testing.T) { From: String("old-repo-name"), }, }, + Topics: &EditTopics{ + From: &[]string{"topic1", "topic2"}, + }, } want := `{ @@ -98,6 +101,12 @@ func TestEditChange_Marshal_Repo(t *testing.T) { "name": { "from": "old-repo-name" } + }, + "topics": { + "from": [ + "topic1", + "topic2" + ] } }` diff --git a/github/github-accessors.go b/github/github-accessors.go index 5a763df1e21..d04f802d92f 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -6358,6 +6358,14 @@ func (e *EditChange) GetTitle() *EditTitle { return e.Title } +// GetTopics returns the Topics field. +func (e *EditChange) GetTopics() *EditTopics { + if e == nil { + return nil + } + return e.Topics +} + // GetFrom returns the From field if it's non-nil, zero value otherwise. func (e *EditDefaultBranch) GetFrom() string { if e == nil || e.From == nil { @@ -6406,6 +6414,14 @@ func (e *EditTitle) GetFrom() string { return *e.From } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (e *EditTopics) GetFrom() []string { + if e == nil || e.From == nil { + return nil + } + return *e.From +} + // GetAvatarURL returns the AvatarURL field if it's non-nil, zero value otherwise. func (e *Enterprise) GetAvatarURL() string { if e == nil || e.AvatarURL == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 5c291306ab2..088ac968b33 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -7414,6 +7414,13 @@ func TestEditChange_GetTitle(tt *testing.T) { e.GetTitle() } +func TestEditChange_GetTopics(tt *testing.T) { + e := &EditChange{} + e.GetTopics() + e = nil + e.GetTopics() +} + func TestEditDefaultBranch_GetFrom(tt *testing.T) { var zeroValue string e := &EditDefaultBranch{From: &zeroValue} @@ -7468,6 +7475,16 @@ func TestEditTitle_GetFrom(tt *testing.T) { e.GetFrom() } +func TestEditTopics_GetFrom(tt *testing.T) { + var zeroValue []string + e := &EditTopics{From: &zeroValue} + e.GetFrom() + e = &EditTopics{} + e.GetFrom() + e = nil + e.GetFrom() +} + func TestEnterprise_GetAvatarURL(tt *testing.T) { var zeroValue string e := &Enterprise{AvatarURL: &zeroValue} From cef0af50911c64a380a50d3ffd3998f0b01510cf Mon Sep 17 00:00:00 2001 From: Riaje Date: Wed, 24 Jan 2024 18:00:11 -0500 Subject: [PATCH 2/3] Add Topics to EditChange struct Fix slice without pointer because it's already a reference type Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/event_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/event_types.go b/github/event_types.go index e4a3a521e66..56db9f5b18c 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -441,7 +441,7 @@ type RepoName struct { // EditTopics represents a change of repository topics. type EditTopics struct { - From *[]string `json:"from,omitempty"` + From []string `json:"from,omitempty"` } // EditSHA represents a sha change of a pull-request. From fbb0520c677289dcd875530030fc7c738417bb5c Mon Sep 17 00:00:00 2001 From: riaje Date: Wed, 24 Jan 2024 18:22:52 -0500 Subject: [PATCH 3/3] Add Topics to EditChange struct --- github/event_types_test.go | 2 +- github/github-accessors.go | 8 -------- github/github-accessors_test.go | 10 ---------- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/github/event_types_test.go b/github/event_types_test.go index 5322f8873f9..8578b922bf6 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -92,7 +92,7 @@ func TestEditChange_Marshal_Repo(t *testing.T) { }, }, Topics: &EditTopics{ - From: &[]string{"topic1", "topic2"}, + From: []string{"topic1", "topic2"}, }, } diff --git a/github/github-accessors.go b/github/github-accessors.go index d04f802d92f..6d32908ce01 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -6414,14 +6414,6 @@ func (e *EditTitle) GetFrom() string { return *e.From } -// GetFrom returns the From field if it's non-nil, zero value otherwise. -func (e *EditTopics) GetFrom() []string { - if e == nil || e.From == nil { - return nil - } - return *e.From -} - // GetAvatarURL returns the AvatarURL field if it's non-nil, zero value otherwise. func (e *Enterprise) GetAvatarURL() string { if e == nil || e.AvatarURL == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 088ac968b33..5856cc7ac25 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -7475,16 +7475,6 @@ func TestEditTitle_GetFrom(tt *testing.T) { e.GetFrom() } -func TestEditTopics_GetFrom(tt *testing.T) { - var zeroValue []string - e := &EditTopics{From: &zeroValue} - e.GetFrom() - e = &EditTopics{} - e.GetFrom() - e = nil - e.GetFrom() -} - func TestEnterprise_GetAvatarURL(tt *testing.T) { var zeroValue string e := &Enterprise{AvatarURL: &zeroValue}