From ace7fec62ea8a884c93a98164680e98266edcadb Mon Sep 17 00:00:00 2001 From: Shyclyde Date: Sun, 1 Oct 2023 12:58:43 -0600 Subject: [PATCH] Add PerformedViaGithubApp and RequestedTeam to IssueEvent --- github/event_types.go | 6 ++ github/event_types_test.go | 148 ++++++++++++++++++++------------ github/github-accessors.go | 24 ++++++ github/github-accessors_test.go | 21 +++++ github/issues_events.go | 26 +++--- github/issues_events_test.go | 56 ++++++++++++ github/issues_timeline.go | 2 + 7 files changed, 215 insertions(+), 68 deletions(-) diff --git a/github/event_types.go b/github/event_types.go index 1a403da9b9d..3161384f15d 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -1086,6 +1086,9 @@ type PullRequestEvent struct { // The following fields are only populated when the Action is "synchronize". Before *string `json:"before,omitempty"` After *string `json:"after,omitempty"` + + // The following will be populated if the event was performed by an App + PerformedViaGithubApp *App `json:"performed_via_github_app,omitempty"` } // PullRequestReviewEvent is triggered when a review is submitted on a pull @@ -1186,6 +1189,9 @@ type PullRequestTargetEvent struct { // The following fields are only populated when the Action is "synchronize". Before *string `json:"before,omitempty"` After *string `json:"after,omitempty"` + + // The following will be populated if the event was performed by an App + PerformedViaGithubApp *App `json:"performed_via_github_app,omitempty"` } // PushEvent represents a git push to a GitHub repository. diff --git a/github/event_types_test.go b/github/event_types_test.go index 31b94479f3b..9f4dd252523 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -15177,6 +15177,15 @@ func TestPullRequestEvent_Marshal(t *testing.T) { URL: String("s"), Name: String("n"), }, + PerformedViaGithubApp: &App{ + ID: Int64(1), + NodeID: String("n"), + Slug: String("s"), + Name: String("n"), + Description: String("d"), + ExternalURL: String("e"), + HTMLURL: String("h"), + }, Organization: &Organization{ BillingEmail: String("be"), Blog: String("b"), @@ -15346,11 +15355,47 @@ func TestPullRequestEvent_Marshal(t *testing.T) { "requested_team": { "id": 1 }, + "label": { + "id": 1 + }, + "before": "before", + "after": "after", "repository": { "id": 1, "name": "n", "url": "s" }, + "performed_via_github_app": { + "id": 1, + "node_id": "n", + "slug": "s", + "name": "n", + "description": "d", + "external_url": "e", + "html_url": "h", + }, + "organization": { + "name": "n", + "company": "c", + "blog": "b", + "location": "loc", + "email": "e", + "twitter_username": "tu", + "description": "d", + "billing_email": "be", + "is_verified": true, + "has_organization_projects": true, + "has_repository_projects": true, + "default_repository_permission": "drp", + "members_can_create_repositories": true, + "members_can_create_public_repositories": false, + "members_can_create_private_repositories": true, + "members_can_create_internal_repositories": true, + "members_allowed_repository_creation_type": "marct", + "members_can_create_pages": true, + "members_can_create_public_pages": false, + "members_can_create_private_pages": true + }, "sender": { "login": "l", "id": 1, @@ -15456,34 +15501,7 @@ func TestPullRequestEvent_Marshal(t *testing.T) { "url": "u" }, "suspended_at": ` + referenceTimeStr + ` - }, - "label": { - "id": 1 - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "before": "before", - "after": "after" + } }` testJSONMarshal(t, u, want) @@ -16060,6 +16078,15 @@ func TestPullRequestTargetEvent_Marshal(t *testing.T) { URL: String("s"), Name: String("n"), }, + PerformedViaGithubApp: &App{ + ID: Int64(1), + NodeID: String("n"), + Slug: String("s"), + Name: String("n"), + Description: String("d"), + ExternalURL: String("e"), + HTMLURL: String("h"), + }, Organization: &Organization{ BillingEmail: String("be"), Blog: String("b"), @@ -16229,11 +16256,47 @@ func TestPullRequestTargetEvent_Marshal(t *testing.T) { "requested_team": { "id": 1 }, + "label": { + "id": 1 + }, + "before": "before", + "after": "after", "repository": { "id": 1, "name": "n", "url": "s" }, + "performed_via_github_app": { + "id": 1, + "node_id": "n", + "slug": "s", + "name": "n", + "description": "d", + "external_url": "e", + "html_url": "h", + }, + "organization": { + "name": "n", + "company": "c", + "blog": "b", + "location": "loc", + "email": "e", + "twitter_username": "tu", + "description": "d", + "billing_email": "be", + "is_verified": true, + "has_organization_projects": true, + "has_repository_projects": true, + "default_repository_permission": "drp", + "members_can_create_repositories": true, + "members_can_create_public_repositories": false, + "members_can_create_private_repositories": true, + "members_can_create_internal_repositories": true, + "members_allowed_repository_creation_type": "marct", + "members_can_create_pages": true, + "members_can_create_public_pages": false, + "members_can_create_private_pages": true + }, "sender": { "login": "l", "id": 1, @@ -16339,34 +16402,7 @@ func TestPullRequestTargetEvent_Marshal(t *testing.T) { "url": "u" }, "suspended_at": ` + referenceTimeStr + ` - }, - "label": { - "id": 1 - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "before": "before", - "after": "after" + } }` testJSONMarshal(t, u, want) diff --git a/github/github-accessors.go b/github/github-accessors.go index b305bfc6448..c4da91eba59 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -16190,6 +16190,14 @@ func (p *PullRequestEvent) GetRequestedTeam() *Team { return p.RequestedTeam } +// GetPerformedViaGithubApp returns the PerformedViaGithubApp field. +func (p *PullRequestEvent) GetPerformedViaGithubApp() *App { + if p == nil { + return nil + } + return p.PerformedViaGithubApp +} + // GetSender returns the Sender field. func (p *PullRequestEvent) GetSender() *User { if p == nil { @@ -16726,6 +16734,14 @@ func (p *PullRequestTargetEvent) GetRequestedTeam() *Team { return p.RequestedTeam } +// GetPerformedViaGithubApp returns the PerformedViaGithubApp field. +func (p *PullRequestTargetEvent) GetPerformedViaGithubApp() *App { + if p == nil { + return nil + } + return p.PerformedViaGithubApp +} + // GetSender returns the Sender field. func (p *PullRequestTargetEvent) GetSender() *User { if p == nil { @@ -22550,6 +22566,14 @@ func (t *Timeline) GetRequestedTeam() *Team { return t.RequestedTeam } +// GetPerformedViaGithubApp returns the PerformedViaGithubApp field. +func (t *Timeline) GetPerformedViaGithubApp() *App { + if t == nil { + return nil + } + return t.PerformedViaGithubApp +} + // GetRequester returns the Requester field. func (t *Timeline) GetRequester() *User { if t == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 962e5e8f733..f39351d0a9f 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -18840,6 +18840,13 @@ func TestPullRequestEvent_GetRequestedTeam(tt *testing.T) { p.GetRequestedTeam() } +func TestPullRequestEvent_GetPerformedViaGithubApp(tt *testing.T) { + p := &PullRequestEvent{} + p.GetPerformedViaGithubApp() + p = nil + p.GetPerformedViaGithubApp() +} + func TestPullRequestEvent_GetSender(tt *testing.T) { p := &PullRequestEvent{} p.GetSender() @@ -19408,6 +19415,13 @@ func TestPullRequestTargetEvent_GetRequestedTeam(tt *testing.T) { p.GetRequestedTeam() } +func TestPullRequestTargetEvent_GetPerformedViaGithubApp(tt *testing.T) { + p := &PullRequestTargetEvent{} + p.GetPerformedViaGithubApp() + p = nil + p.GetPerformedViaGithubApp() +} + func TestPullRequestTargetEvent_GetSender(tt *testing.T) { p := &PullRequestTargetEvent{} p.GetSender() @@ -26235,6 +26249,13 @@ func TestTimeline_GetRequestedTeam(tt *testing.T) { t.GetRequestedTeam() } +func TestTimeline_GetPerformedViaGithubApp(tt *testing.T) { + t := &Timeline{} + t.GetPerformedViaGithubApp() + t = nil + t.GetPerformedViaGithubApp() +} + func TestTimeline_GetRequester(tt *testing.T) { t := &Timeline{} t.GetRequester() diff --git a/github/issues_events.go b/github/issues_events.go index ed076591701..0305fca1168 100644 --- a/github/issues_events.go +++ b/github/issues_events.go @@ -66,7 +66,7 @@ type IssueEvent struct { // // review_requested, review_request_removed // The Actor requested or removed the request for a review. - // RequestedReviewer and ReviewRequester will be populated below. + // RequestedReviewer or RequestedTeam, and ReviewRequester will be populated below. // Event *string `json:"event,omitempty"` @@ -74,17 +74,19 @@ type IssueEvent struct { Issue *Issue `json:"issue,omitempty"` // Only present on certain events; see above. - Assignee *User `json:"assignee,omitempty"` - Assigner *User `json:"assigner,omitempty"` - CommitID *string `json:"commit_id,omitempty"` - Milestone *Milestone `json:"milestone,omitempty"` - Label *Label `json:"label,omitempty"` - Rename *Rename `json:"rename,omitempty"` - LockReason *string `json:"lock_reason,omitempty"` - ProjectCard *ProjectCard `json:"project_card,omitempty"` - DismissedReview *DismissedReview `json:"dismissed_review,omitempty"` - RequestedReviewer *User `json:"requested_reviewer,omitempty"` - ReviewRequester *User `json:"review_requester,omitempty"` + Assignee *User `json:"assignee,omitempty"` + Assigner *User `json:"assigner,omitempty"` + CommitID *string `json:"commit_id,omitempty"` + Milestone *Milestone `json:"milestone,omitempty"` + Label *Label `json:"label,omitempty"` + Rename *Rename `json:"rename,omitempty"` + LockReason *string `json:"lock_reason,omitempty"` + ProjectCard *ProjectCard `json:"project_card,omitempty"` + DismissedReview *DismissedReview `json:"dismissed_review,omitempty"` + RequestedReviewer *User `json:"requested_reviewer,omitempty"` + RequestedTeam *Team `json:"requested_team,omitempty"` + ReviewRequester *User `json:"review_requester,omitempty"` + PerformedViaGithubApp *App `json:"performed_via_github_app,omitempty"` } // DismissedReview represents details for 'dismissed_review' events. diff --git a/github/issues_events_test.go b/github/issues_events_test.go index 1d8d3233d19..6b327b2351e 100644 --- a/github/issues_events_test.go +++ b/github/issues_events_test.go @@ -270,6 +270,62 @@ func TestIssueEvent_Marshal(t *testing.T) { CreatedAt: &Timestamp{referenceTime}, SuspendedAt: &Timestamp{referenceTime}, }, + RequestedTeam: &Team{ + ID: Int64(1), + NodeID: String("n"), + Name: String("n"), + Description: String("d"), + URL: String("u"), + Slug: String("s"), + Permission: String("p"), + Privacy: String("p"), + MembersCount: Int(1), + ReposCount: Int(1), + MembersURL: String("m"), + RepositoriesURL: String("r"), + Organization: &Organization{ + Login: String("l"), + ID: Int64(1), + NodeID: String("n"), + AvatarURL: String("a"), + HTMLURL: String("h"), + Name: String("n"), + Company: String("c"), + Blog: String("b"), + Location: String("l"), + Email: String("e"), + }, + Parent: &Team{ + ID: Int64(1), + NodeID: String("n"), + Name: String("n"), + Description: String("d"), + URL: String("u"), + Slug: String("s"), + Permission: String("p"), + Privacy: String("p"), + MembersCount: Int(1), + ReposCount: Int(1), + }, + LDAPDN: String("l"), + }, + PerformedViaGithubApp: &App{ + ID: Int64(1), + NodeID: String("n"), + Owner: &User{ + Login: String("l"), + ID: Int64(1), + NodeID: String("n"), + URL: String("u"), + ReposURL: String("r"), + EventsURL: String("e"), + AvatarURL: String("a"), + }, + Name: String("n"), + Description: String("d"), + HTMLURL: String("h"), + ExternalURL: String("u"), + }, ReviewRequester: &User{ Login: String("l"), ID: Int64(1), diff --git a/github/issues_timeline.go b/github/issues_timeline.go index 9c73e6176d1..8ac02ac14dc 100644 --- a/github/issues_timeline.go +++ b/github/issues_timeline.go @@ -151,6 +151,8 @@ type Timeline struct { // The review summary text. Body *string `json:"body,omitempty"` SubmittedAt *Timestamp `json:"submitted_at,omitempty"` + + PerformedViaGithubApp *App `json:"performed_via_github_app,omitempty"` } // Source represents a reference's source.