Skip to content

Commit 19b1a93

Browse files
authored
Add Changes field to RepositoryEvent (#2233)
Fixes: #2232 .
1 parent 6bc0adb commit 19b1a93

File tree

4 files changed

+99
-2
lines changed

4 files changed

+99
-2
lines changed

github/event_types.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,13 @@ type GollumEvent struct {
230230
Installation *Installation `json:"installation,omitempty"`
231231
}
232232

233-
// EditChange represents the changes when an issue, pull request, or comment has
234-
// been edited.
233+
// EditChange represents the changes when an issue, pull request, comment,
234+
// or repository has been edited.
235235
type EditChange struct {
236236
Title *EditTitle `json:"title,omitempty"`
237237
Body *EditBody `json:"body,omitempty"`
238238
Base *EditBase `json:"base,omitempty"`
239+
Repo *EditRepo `json:"repository,omitempty"`
239240
}
240241

241242
// EditTitle represents a pull-request title change.
@@ -259,6 +260,16 @@ type EditRef struct {
259260
From *string `json:"from,omitempty"`
260261
}
261262

263+
// EditRepo represents a change of repository name.
264+
type EditRepo struct {
265+
Name *RepoName `json:"name,omitempty"`
266+
}
267+
268+
// RepoName represents a change of repository name.
269+
type RepoName struct {
270+
From *string `json:"from,omitempty"`
271+
}
272+
262273
// EditSHA represents a sha change of a pull-request.
263274
type EditSHA struct {
264275
From *string `json:"from,omitempty"`
@@ -938,6 +949,7 @@ type RepositoryEvent struct {
938949
Repo *Repository `json:"repository,omitempty"`
939950

940951
// The following fields are only populated by Webhook events.
952+
Changes *EditChange `json:"changes,omitempty"`
941953
Org *Organization `json:"organization,omitempty"`
942954
Sender *User `json:"sender,omitempty"`
943955
Installation *Installation `json:"installation,omitempty"`

github/event_types_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,28 @@ func TestEditChange_Marshal_BaseChange(t *testing.T) {
8282
testJSONMarshal(t, u, want)
8383
}
8484

85+
func TestEditChange_Marshal_Repo(t *testing.T) {
86+
testJSONMarshal(t, &EditChange{}, "{}")
87+
88+
u := &EditChange{
89+
Repo: &EditRepo{
90+
Name: &RepoName{
91+
From: String("old-repo-name"),
92+
},
93+
},
94+
}
95+
96+
want := `{
97+
"repository": {
98+
"name": {
99+
"from": "old-repo-name"
100+
}
101+
}
102+
}`
103+
104+
testJSONMarshal(t, u, want)
105+
}
106+
85107
func TestProjectChange_Marshal_NameChange(t *testing.T) {
86108
testJSONMarshal(t, &ProjectChange{}, "{}")
87109

github/github-accessors.go

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)