Skip to content

Commit c2ddceb

Browse files
committed
Merge #1900
2 parents c26abbd + 9036cc0 commit c2ddceb

File tree

9 files changed

+1008
-175
lines changed

9 files changed

+1008
-175
lines changed

github/activity.go

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,25 @@ type FeedLink struct {
2121

2222
// Feeds represents timeline resources in Atom format.
2323
type Feeds struct {
24-
TimelineURL *string `json:"timeline_url,omitempty"`
25-
UserURL *string `json:"user_url,omitempty"`
26-
CurrentUserPublicURL *string `json:"current_user_public_url,omitempty"`
27-
CurrentUserURL *string `json:"current_user_url,omitempty"`
28-
CurrentUserActorURL *string `json:"current_user_actor_url,omitempty"`
29-
CurrentUserOrganizationURL *string `json:"current_user_organization_url,omitempty"`
30-
CurrentUserOrganizationURLs []string `json:"current_user_organization_urls,omitempty"`
31-
Links *struct {
32-
Timeline *FeedLink `json:"timeline,omitempty"`
33-
User *FeedLink `json:"user,omitempty"`
34-
CurrentUserPublic *FeedLink `json:"current_user_public,omitempty"`
35-
CurrentUser *FeedLink `json:"current_user,omitempty"`
36-
CurrentUserActor *FeedLink `json:"current_user_actor,omitempty"`
37-
CurrentUserOrganization *FeedLink `json:"current_user_organization,omitempty"`
38-
CurrentUserOrganizations []*FeedLink `json:"current_user_organizations,omitempty"`
39-
} `json:"_links,omitempty"`
24+
TimelineURL *string `json:"timeline_url,omitempty"`
25+
UserURL *string `json:"user_url,omitempty"`
26+
CurrentUserPublicURL *string `json:"current_user_public_url,omitempty"`
27+
CurrentUserURL *string `json:"current_user_url,omitempty"`
28+
CurrentUserActorURL *string `json:"current_user_actor_url,omitempty"`
29+
CurrentUserOrganizationURL *string `json:"current_user_organization_url,omitempty"`
30+
CurrentUserOrganizationURLs []string `json:"current_user_organization_urls,omitempty"`
31+
Links *FeedLinks `json:"_links,omitempty"`
32+
}
33+
34+
// FeedLinks represents the links in a Feed.
35+
type FeedLinks struct {
36+
Timeline *FeedLink `json:"timeline,omitempty"`
37+
User *FeedLink `json:"user,omitempty"`
38+
CurrentUserPublic *FeedLink `json:"current_user_public,omitempty"`
39+
CurrentUser *FeedLink `json:"current_user,omitempty"`
40+
CurrentUserActor *FeedLink `json:"current_user_actor,omitempty"`
41+
CurrentUserOrganization *FeedLink `json:"current_user_organization,omitempty"`
42+
CurrentUserOrganizations []*FeedLink `json:"current_user_organizations,omitempty"`
4043
}
4144

4245
// ListFeeds lists all the feeds available to the authenticated user.

github/activity_test.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,7 @@ var wantFeeds = &Feeds{
9797
CurrentUserOrganizationURLs: []string{
9898
"https://github.com/organizations/github/defunkt.private.atom?token=abc123",
9999
},
100-
Links: &struct {
101-
Timeline *FeedLink `json:"timeline,omitempty"`
102-
User *FeedLink `json:"user,omitempty"`
103-
CurrentUserPublic *FeedLink `json:"current_user_public,omitempty"`
104-
CurrentUser *FeedLink `json:"current_user,omitempty"`
105-
CurrentUserActor *FeedLink `json:"current_user_actor,omitempty"`
106-
CurrentUserOrganization *FeedLink `json:"current_user_organization,omitempty"`
107-
CurrentUserOrganizations []*FeedLink `json:"current_user_organizations,omitempty"`
108-
}{
100+
Links: &FeedLinks{
109101
Timeline: &FeedLink{
110102
HRef: String("https://github.com/timeline"),
111103
Type: String("application/atom+xml"),

github/event_types.go

Lines changed: 106 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -215,66 +215,111 @@ type GollumEvent struct {
215215
// EditChange represents the changes when an issue, pull request, or comment has
216216
// been edited.
217217
type EditChange struct {
218-
Title *struct {
219-
From *string `json:"from,omitempty"`
220-
} `json:"title,omitempty"`
221-
Body *struct {
222-
From *string `json:"from,omitempty"`
223-
} `json:"body,omitempty"`
224-
Base *struct {
225-
Ref *struct {
226-
From *string `json:"from,omitempty"`
227-
} `json:"ref,omitempty"`
228-
SHA *struct {
229-
From *string `json:"from,omitempty"`
230-
} `json:"sha,omitempty"`
231-
} `json:"base,omitempty"`
218+
Title *EditTitle `json:"title,omitempty"`
219+
Body *EditBody `json:"body,omitempty"`
220+
Base *EditBase `json:"base,omitempty"`
221+
}
222+
223+
// EditTitle represents a pull-request title change.
224+
type EditTitle struct {
225+
From *string `json:"from,omitempty"`
226+
}
227+
228+
// EditBody represents a change of pull-request body.
229+
type EditBody struct {
230+
From *string `json:"from,omitempty"`
231+
}
232+
233+
// EditBase represents the change of a pull-request base branch.
234+
type EditBase struct {
235+
Ref *EditRef `json:"ref,omitempty"`
236+
SHA *EditSHA `json:"sha,omitempty"`
237+
}
238+
239+
// EditRef represents a ref change of a pull-request.
240+
type EditRef struct {
241+
From *string `json:"from,omitempty"`
242+
}
243+
244+
// EditSHA represents a sha change of a pull-request.
245+
type EditSHA struct {
246+
From *string `json:"from,omitempty"`
232247
}
233248

234249
// ProjectChange represents the changes when a project has been edited.
235250
type ProjectChange struct {
236-
Name *struct {
237-
From *string `json:"from,omitempty"`
238-
} `json:"name,omitempty"`
239-
Body *struct {
240-
From *string `json:"from,omitempty"`
241-
} `json:"body,omitempty"`
251+
Name *ProjectName `json:"name,omitempty"`
252+
Body *ProjectBody `json:"body,omitempty"`
253+
}
254+
255+
// ProjectName represents a project name change.
256+
type ProjectName struct {
257+
From *string `json:"from,omitempty"`
258+
}
259+
260+
// ProjectBody represents a project body change.
261+
type ProjectBody struct {
262+
From *string `json:"from,omitempty"`
242263
}
243264

244265
// ProjectCardChange represents the changes when a project card has been edited.
245266
type ProjectCardChange struct {
246-
Note *struct {
247-
From *string `json:"from,omitempty"`
248-
} `json:"note,omitempty"`
267+
Note *ProjectCardNote `json:"note,omitempty"`
268+
}
269+
270+
// ProjectCardNote represents a change of a note of a project card.
271+
type ProjectCardNote struct {
272+
From *string `json:"from,omitempty"`
249273
}
250274

251275
// ProjectColumnChange represents the changes when a project column has been edited.
252276
type ProjectColumnChange struct {
253-
Name *struct {
254-
From *string `json:"from,omitempty"`
255-
} `json:"name,omitempty"`
277+
Name *ProjectColumnName `json:"name,omitempty"`
278+
}
279+
280+
// ProjectColumnName represents a project column name change.
281+
type ProjectColumnName struct {
282+
From *string `json:"from,omitempty"`
256283
}
257284

258285
// TeamChange represents the changes when a team has been edited.
259286
type TeamChange struct {
260-
Description *struct {
261-
From *string `json:"from,omitempty"`
262-
} `json:"description,omitempty"`
263-
Name *struct {
264-
From *string `json:"from,omitempty"`
265-
} `json:"name,omitempty"`
266-
Privacy *struct {
267-
From *string `json:"from,omitempty"`
268-
} `json:"privacy,omitempty"`
269-
Repository *struct {
270-
Permissions *struct {
271-
From *struct {
272-
Admin *bool `json:"admin,omitempty"`
273-
Pull *bool `json:"pull,omitempty"`
274-
Push *bool `json:"push,omitempty"`
275-
} `json:"from,omitempty"`
276-
} `json:"permissions,omitempty"`
277-
} `json:"repository,omitempty"`
287+
Description *TeamDescription `json:"description,omitempty"`
288+
Name *TeamName `json:"name,omitempty"`
289+
Privacy *TeamPrivacy `json:"privacy,omitempty"`
290+
Repository *TeamRepository `json:"repository,omitempty"`
291+
}
292+
293+
// TeamDescription represents a team description change.
294+
type TeamDescription struct {
295+
From *string `json:"from,omitempty"`
296+
}
297+
298+
// TeamName represents a team name change.
299+
type TeamName struct {
300+
From *string `json:"from,omitempty"`
301+
}
302+
303+
// TeamPrivacy represents a team privacy change.
304+
type TeamPrivacy struct {
305+
From *string `json:"from,omitempty"`
306+
}
307+
308+
// TeamRepository represents a team repository permission change.
309+
type TeamRepository struct {
310+
Permissions *TeamPermissions `json:"permissions,omitempty"`
311+
}
312+
313+
// TeamPermissions represents a team permission change.
314+
type TeamPermissions struct {
315+
From *TeamPermissionsFrom `json:"from,omitempty"`
316+
}
317+
318+
// TeamPermissionsFrom represents a team permission change.
319+
type TeamPermissionsFrom struct {
320+
Admin *bool `json:"admin,omitempty"`
321+
Pull *bool `json:"pull,omitempty"`
322+
Push *bool `json:"push,omitempty"`
278323
}
279324

280325
// InstallationEvent is triggered when a GitHub App has been installed, uninstalled, suspend, unsuspended
@@ -890,25 +935,28 @@ type RepositoryVulnerabilityAlertEvent struct {
890935
Action *string `json:"action,omitempty"`
891936

892937
//The security alert of the vulnerable dependency.
893-
Alert *struct {
894-
ID *int64 `json:"id,omitempty"`
895-
AffectedRange *string `json:"affected_range,omitempty"`
896-
AffectedPackageName *string `json:"affected_package_name,omitempty"`
897-
ExternalReference *string `json:"external_reference,omitempty"`
898-
ExternalIdentifier *string `json:"external_identifier,omitempty"`
899-
GitHubSecurityAdvisoryID *string `json:"ghsa_id,omitempty"`
900-
Severity *string `json:"severity,omitempty"`
901-
CreatedAt *Timestamp `json:"created_at,omitempty"`
902-
FixedIn *string `json:"fixed_in,omitempty"`
903-
Dismisser *User `json:"dismisser,omitempty"`
904-
DismissReason *string `json:"dismiss_reason,omitempty"`
905-
DismissedAt *Timestamp `json:"dismissed_at,omitempty"`
906-
} `json:"alert,omitempty"`
938+
Alert *RepositoryVulnerabilityAlert `json:"alert,omitempty"`
907939

908940
//The repository of the vulnerable dependency.
909941
Repository *Repository `json:"repository,omitempty"`
910942
}
911943

944+
// RepositoryVulnerabilityAlert represents a repository security alert.
945+
type RepositoryVulnerabilityAlert struct {
946+
ID *int64 `json:"id,omitempty"`
947+
AffectedRange *string `json:"affected_range,omitempty"`
948+
AffectedPackageName *string `json:"affected_package_name,omitempty"`
949+
ExternalReference *string `json:"external_reference,omitempty"`
950+
ExternalIdentifier *string `json:"external_identifier,omitempty"`
951+
GitHubSecurityAdvisoryID *string `json:"ghsa_id,omitempty"`
952+
Severity *string `json:"severity,omitempty"`
953+
CreatedAt *Timestamp `json:"created_at,omitempty"`
954+
FixedIn *string `json:"fixed_in,omitempty"`
955+
Dismisser *User `json:"dismisser,omitempty"`
956+
DismissReason *string `json:"dismiss_reason,omitempty"`
957+
DismissedAt *Timestamp `json:"dismissed_at,omitempty"`
958+
}
959+
912960
// StarEvent is triggered when a star is added or removed from a repository.
913961
// The Webhook event name is "star".
914962
//

github/event_types_test.go

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,12 @@ import (
1212
func TestEditChange_Marshal_TitleChange(t *testing.T) {
1313
testJSONMarshal(t, &EditChange{}, "{}")
1414

15-
TitleFrom := struct {
16-
From *string `json:"from,omitempty"`
17-
}{
18-
From: String("TitleFrom"),
19-
}
20-
2115
u := &EditChange{
22-
Title: &TitleFrom,
23-
Body: nil,
24-
Base: nil,
16+
Title: &EditTitle{
17+
From: String("TitleFrom"),
18+
},
19+
Body: nil,
20+
Base: nil,
2521
}
2622

2723
want := `{
@@ -36,16 +32,12 @@ func TestEditChange_Marshal_TitleChange(t *testing.T) {
3632
func TestEditChange_Marshal_BodyChange(t *testing.T) {
3733
testJSONMarshal(t, &EditChange{}, "{}")
3834

39-
BodyFrom := struct {
40-
From *string `json:"from,omitempty"`
41-
}{
42-
From: String("BodyFrom"),
43-
}
44-
4535
u := &EditChange{
4636
Title: nil,
47-
Body: &BodyFrom,
48-
Base: nil,
37+
Body: &EditBody{
38+
From: String("BodyFrom"),
39+
},
40+
Base: nil,
4941
}
5042

5143
want := `{
@@ -60,28 +52,13 @@ func TestEditChange_Marshal_BodyChange(t *testing.T) {
6052
func TestEditChange_Marshal_BaseChange(t *testing.T) {
6153
testJSONMarshal(t, &EditChange{}, "{}")
6254

63-
RefFrom := struct {
64-
From *string `json:"from,omitempty"`
65-
}{
66-
From: String("BaseRefFrom"),
67-
}
68-
69-
SHAFrom := struct {
70-
From *string `json:"from,omitempty"`
71-
}{
72-
From: String("BaseSHAFrom"),
73-
}
74-
75-
Base := struct {
76-
Ref *struct {
77-
From *string `json:"from,omitempty"`
78-
} `json:"ref,omitempty"`
79-
SHA *struct {
80-
From *string `json:"from,omitempty"`
81-
} `json:"sha,omitempty"`
82-
}{
83-
Ref: &RefFrom,
84-
SHA: &SHAFrom,
55+
Base := EditBase{
56+
Ref: &EditRef{
57+
From: String("BaseRefFrom"),
58+
},
59+
SHA: &EditSHA{
60+
From: String("BaseSHAFrom"),
61+
},
8562
}
8663

8764
u := &EditChange{

0 commit comments

Comments
 (0)