Repository: google/go-github
Pull request #3057 (2024-01-24 22:48:07)

Add Topics to EditChange struct
Fixes: https://github.com/google/go-github/issues/3056

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/google/go-github/pull/3057?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Comparison is base [(`b61795d`)](https://app.codecov.io/gh/google/go-github/commit/b61795d74253456297d180698c1aada6978e0e67?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) 97.71% compared to head [(`736bd7a`)](https://app.codecov.io/gh/google/go-github/pull/3057?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) 97.71%.


<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master    #3057   +/-   ##
=======================================
  Coverage   97.71%   97.71%           
=======================================
  Files         152      152           
  Lines       13326    13326           
=======================================
  Hits        13021    13021           
  Misses        215      215           
  Partials       90       90           
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/google/go-github/pull/3057?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).

riaje: I will fix the tests, sorry I have made my commit a bit too faster 

Patch:
diff --git a/github/event_types.go b/github/event_types.go
index db7c7c69..56db9f5b 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/github-accessors.go b/github/github-accessors.go
index 5a763df1..6d32908c 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 {


Test patch:
diff --git a/github/event_types_test.go b/github/event_types_test.go
index 80eca61d..8578b922 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_test.go b/github/github-accessors_test.go
index 5c291306..5856cc7a 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}