From fc8e53696f320e10960163836ad62a56aed6a3cc Mon Sep 17 00:00:00 2001 From: James Loh Date: Fri, 7 May 2021 21:51:33 +1000 Subject: [PATCH] Add missing fields to Star event Fixes https://github.com/google/go-github/issues/1868 --- github/event_types.go | 5 +++++ github/github-accessors.go | 24 ++++++++++++++++++++++++ github/github-accessors_test.go | 21 +++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/github/event_types.go b/github/event_types.go index c5fedb25e7b..48347f37d04 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -916,6 +916,11 @@ type StarEvent struct { // StarredAt is the time the star was created. It will be null for the "deleted" action. StarredAt *Timestamp `json:"starred_at,omitempty"` + + // The following fields are only populated by Webhook events. + Org *Organization `json:"organization,omitempty"` + Repo *Repository `json:"repository,omitempty"` + Sender *User `json:"sender,omitempty"` } // StatusEvent is triggered when the status of a Git commit changes. diff --git a/github/github-accessors.go b/github/github-accessors.go index 081083415b3..b0f0630640a 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -13884,6 +13884,30 @@ func (s *StarEvent) GetAction() string { return *s.Action } +// GetOrg returns the Org field. +func (s *StarEvent) GetOrg() *Organization { + if s == nil { + return nil + } + return s.Org +} + +// GetRepo returns the Repo field. +func (s *StarEvent) GetRepo() *Repository { + if s == nil { + return nil + } + return s.Repo +} + +// GetSender returns the Sender field. +func (s *StarEvent) GetSender() *User { + if s == nil { + return nil + } + return s.Sender +} + // GetStarredAt returns the StarredAt field if it's non-nil, zero value otherwise. func (s *StarEvent) GetStarredAt() Timestamp { if s == nil || s.StarredAt == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 49ceb123953..12c38dd4e97 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -16273,6 +16273,27 @@ func TestStarEvent_GetAction(tt *testing.T) { s.GetAction() } +func TestStarEvent_GetOrg(tt *testing.T) { + s := &StarEvent{} + s.GetOrg() + s = nil + s.GetOrg() +} + +func TestStarEvent_GetRepo(tt *testing.T) { + s := &StarEvent{} + s.GetRepo() + s = nil + s.GetRepo() +} + +func TestStarEvent_GetSender(tt *testing.T) { + s := &StarEvent{} + s.GetSender() + s = nil + s.GetSender() +} + func TestStarEvent_GetStarredAt(tt *testing.T) { var zeroValue Timestamp s := &StarEvent{StarredAt: &zeroValue}