From 874e9c17a111bf36b9526649b9d68f40b63a603e Mon Sep 17 00:00:00 2001 From: coding-CEO Date: Wed, 24 Sep 2025 15:19:17 +0900 Subject: [PATCH] Add Reason field to PullRequestEvent - Add Reason *string field to PullRequestEvent struct - Field is populated in 'dequeued' event deliveries - Update tests to include new field in JSON marshaling - Generate accessor method GetReason() with corresponding tests This change supports the new 'dequeued' action in pull request webhook events, allowing consumers to access the reason when a pull request is dequeued from a merge queue. --- github/event_types.go | 3 ++- github/event_types_test.go | 2 ++ github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 11 +++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/github/event_types.go b/github/event_types.go index 480ed8dfb96..80b0cf0485b 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -1237,7 +1237,8 @@ type PullRequestEvent struct { Repo *Repository `json:"repository,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` - Label *Label `json:"label,omitempty"` // Populated in "labeled" event deliveries. + Label *Label `json:"label,omitempty"` // Populated in "labeled" event deliveries. + Reason *string `json:"reason,omitempty"` // Populated in "dequeued" event deliveries. // The following field is only present when the webhook is triggered on // a repository belonging to an organization. diff --git a/github/event_types_test.go b/github/event_types_test.go index 6bc9f799e4e..9ad223dca69 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -16079,6 +16079,7 @@ func TestPullRequestEvent_Marshal(t *testing.T) { }, RequestedTeam: &Team{ID: Ptr(int64(1))}, Label: &Label{ID: Ptr(int64(1))}, + Reason: Ptr("CI_FAILURE"), Before: Ptr("before"), After: Ptr("after"), Repo: &Repository{ @@ -16268,6 +16269,7 @@ func TestPullRequestEvent_Marshal(t *testing.T) { "label": { "id": 1 }, + "reason": "CI_FAILURE", "before": "before", "after": "after", "repository": { diff --git a/github/github-accessors.go b/github/github-accessors.go index b470ba80255..6f03afa99ba 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -19918,6 +19918,14 @@ func (p *PullRequestEvent) GetPullRequest() *PullRequest { return p.PullRequest } +// GetReason returns the Reason field if it's non-nil, zero value otherwise. +func (p *PullRequestEvent) GetReason() string { + if p == nil || p.Reason == nil { + return "" + } + return *p.Reason +} + // GetRepo returns the Repo field. func (p *PullRequestEvent) GetRepo() *Repository { if p == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index d61b00e5f69..59282ed1f07 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -25751,6 +25751,17 @@ func TestPullRequestEvent_GetPullRequest(tt *testing.T) { p.GetPullRequest() } +func TestPullRequestEvent_GetReason(tt *testing.T) { + tt.Parallel() + var zeroValue string + p := &PullRequestEvent{Reason: &zeroValue} + p.GetReason() + p = &PullRequestEvent{} + p.GetReason() + p = nil + p.GetReason() +} + func TestPullRequestEvent_GetRepo(tt *testing.T) { tt.Parallel() p := &PullRequestEvent{}