From 390ab50cc0947aebf711ba142c9466f4d21cf2c5 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Fri, 6 Aug 2021 14:47:33 -0400 Subject: [PATCH 1/5] Deprecate WebHookPayload --- github/github-accessors.go | 184 ---------------------------- github/github-accessors_test.go | 206 -------------------------------- github/github-stringify_test.go | 49 -------- github/repos_hooks.go | 51 +------- github/strings_test.go | 6 +- 5 files changed, 9 insertions(+), 487 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 37a22830e61..e75851e2328 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -16964,190 +16964,6 @@ func (w *WatchEvent) GetSender() *User { return w.Sender } -// GetEmail returns the Email field if it's non-nil, zero value otherwise. -func (w *WebHookAuthor) GetEmail() string { - if w == nil || w.Email == nil { - return "" - } - return *w.Email -} - -// GetName returns the Name field if it's non-nil, zero value otherwise. -func (w *WebHookAuthor) GetName() string { - if w == nil || w.Name == nil { - return "" - } - return *w.Name -} - -// GetUsername returns the Username field if it's non-nil, zero value otherwise. -func (w *WebHookAuthor) GetUsername() string { - if w == nil || w.Username == nil { - return "" - } - return *w.Username -} - -// GetAuthor returns the Author field. -func (w *WebHookCommit) GetAuthor() *WebHookAuthor { - if w == nil { - return nil - } - return w.Author -} - -// GetCommitter returns the Committer field. -func (w *WebHookCommit) GetCommitter() *WebHookAuthor { - if w == nil { - return nil - } - return w.Committer -} - -// GetDistinct returns the Distinct field if it's non-nil, zero value otherwise. -func (w *WebHookCommit) GetDistinct() bool { - if w == nil || w.Distinct == nil { - return false - } - return *w.Distinct -} - -// GetID returns the ID field if it's non-nil, zero value otherwise. -func (w *WebHookCommit) GetID() string { - if w == nil || w.ID == nil { - return "" - } - return *w.ID -} - -// GetMessage returns the Message field if it's non-nil, zero value otherwise. -func (w *WebHookCommit) GetMessage() string { - if w == nil || w.Message == nil { - return "" - } - return *w.Message -} - -// GetTimestamp returns the Timestamp field if it's non-nil, zero value otherwise. -func (w *WebHookCommit) GetTimestamp() time.Time { - if w == nil || w.Timestamp == nil { - return time.Time{} - } - return *w.Timestamp -} - -// GetAction returns the Action field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetAction() string { - if w == nil || w.Action == nil { - return "" - } - return *w.Action -} - -// GetAfter returns the After field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetAfter() string { - if w == nil || w.After == nil { - return "" - } - return *w.After -} - -// GetBefore returns the Before field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetBefore() string { - if w == nil || w.Before == nil { - return "" - } - return *w.Before -} - -// GetCompare returns the Compare field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetCompare() string { - if w == nil || w.Compare == nil { - return "" - } - return *w.Compare -} - -// GetCreated returns the Created field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetCreated() bool { - if w == nil || w.Created == nil { - return false - } - return *w.Created -} - -// GetDeleted returns the Deleted field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetDeleted() bool { - if w == nil || w.Deleted == nil { - return false - } - return *w.Deleted -} - -// GetForced returns the Forced field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetForced() bool { - if w == nil || w.Forced == nil { - return false - } - return *w.Forced -} - -// GetHeadCommit returns the HeadCommit field. -func (w *WebHookPayload) GetHeadCommit() *WebHookCommit { - if w == nil { - return nil - } - return w.HeadCommit -} - -// GetInstallation returns the Installation field. -func (w *WebHookPayload) GetInstallation() *Installation { - if w == nil { - return nil - } - return w.Installation -} - -// GetOrganization returns the Organization field. -func (w *WebHookPayload) GetOrganization() *Organization { - if w == nil { - return nil - } - return w.Organization -} - -// GetPusher returns the Pusher field. -func (w *WebHookPayload) GetPusher() *User { - if w == nil { - return nil - } - return w.Pusher -} - -// GetRef returns the Ref field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetRef() string { - if w == nil || w.Ref == nil { - return "" - } - return *w.Ref -} - -// GetRepo returns the Repo field. -func (w *WebHookPayload) GetRepo() *Repository { - if w == nil { - return nil - } - return w.Repo -} - -// GetSender returns the Sender field. -func (w *WebHookPayload) GetSender() *User { - if w == nil { - return nil - } - return w.Sender -} - // GetTotal returns the Total field if it's non-nil, zero value otherwise. func (w *WeeklyCommitActivity) GetTotal() int { if w == nil || w.Total == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 04bf837a1f7..e671531a2a0 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -19880,212 +19880,6 @@ func TestWatchEvent_GetSender(tt *testing.T) { w.GetSender() } -func TestWebHookAuthor_GetEmail(tt *testing.T) { - var zeroValue string - w := &WebHookAuthor{Email: &zeroValue} - w.GetEmail() - w = &WebHookAuthor{} - w.GetEmail() - w = nil - w.GetEmail() -} - -func TestWebHookAuthor_GetName(tt *testing.T) { - var zeroValue string - w := &WebHookAuthor{Name: &zeroValue} - w.GetName() - w = &WebHookAuthor{} - w.GetName() - w = nil - w.GetName() -} - -func TestWebHookAuthor_GetUsername(tt *testing.T) { - var zeroValue string - w := &WebHookAuthor{Username: &zeroValue} - w.GetUsername() - w = &WebHookAuthor{} - w.GetUsername() - w = nil - w.GetUsername() -} - -func TestWebHookCommit_GetAuthor(tt *testing.T) { - w := &WebHookCommit{} - w.GetAuthor() - w = nil - w.GetAuthor() -} - -func TestWebHookCommit_GetCommitter(tt *testing.T) { - w := &WebHookCommit{} - w.GetCommitter() - w = nil - w.GetCommitter() -} - -func TestWebHookCommit_GetDistinct(tt *testing.T) { - var zeroValue bool - w := &WebHookCommit{Distinct: &zeroValue} - w.GetDistinct() - w = &WebHookCommit{} - w.GetDistinct() - w = nil - w.GetDistinct() -} - -func TestWebHookCommit_GetID(tt *testing.T) { - var zeroValue string - w := &WebHookCommit{ID: &zeroValue} - w.GetID() - w = &WebHookCommit{} - w.GetID() - w = nil - w.GetID() -} - -func TestWebHookCommit_GetMessage(tt *testing.T) { - var zeroValue string - w := &WebHookCommit{Message: &zeroValue} - w.GetMessage() - w = &WebHookCommit{} - w.GetMessage() - w = nil - w.GetMessage() -} - -func TestWebHookCommit_GetTimestamp(tt *testing.T) { - var zeroValue time.Time - w := &WebHookCommit{Timestamp: &zeroValue} - w.GetTimestamp() - w = &WebHookCommit{} - w.GetTimestamp() - w = nil - w.GetTimestamp() -} - -func TestWebHookPayload_GetAction(tt *testing.T) { - var zeroValue string - w := &WebHookPayload{Action: &zeroValue} - w.GetAction() - w = &WebHookPayload{} - w.GetAction() - w = nil - w.GetAction() -} - -func TestWebHookPayload_GetAfter(tt *testing.T) { - var zeroValue string - w := &WebHookPayload{After: &zeroValue} - w.GetAfter() - w = &WebHookPayload{} - w.GetAfter() - w = nil - w.GetAfter() -} - -func TestWebHookPayload_GetBefore(tt *testing.T) { - var zeroValue string - w := &WebHookPayload{Before: &zeroValue} - w.GetBefore() - w = &WebHookPayload{} - w.GetBefore() - w = nil - w.GetBefore() -} - -func TestWebHookPayload_GetCompare(tt *testing.T) { - var zeroValue string - w := &WebHookPayload{Compare: &zeroValue} - w.GetCompare() - w = &WebHookPayload{} - w.GetCompare() - w = nil - w.GetCompare() -} - -func TestWebHookPayload_GetCreated(tt *testing.T) { - var zeroValue bool - w := &WebHookPayload{Created: &zeroValue} - w.GetCreated() - w = &WebHookPayload{} - w.GetCreated() - w = nil - w.GetCreated() -} - -func TestWebHookPayload_GetDeleted(tt *testing.T) { - var zeroValue bool - w := &WebHookPayload{Deleted: &zeroValue} - w.GetDeleted() - w = &WebHookPayload{} - w.GetDeleted() - w = nil - w.GetDeleted() -} - -func TestWebHookPayload_GetForced(tt *testing.T) { - var zeroValue bool - w := &WebHookPayload{Forced: &zeroValue} - w.GetForced() - w = &WebHookPayload{} - w.GetForced() - w = nil - w.GetForced() -} - -func TestWebHookPayload_GetHeadCommit(tt *testing.T) { - w := &WebHookPayload{} - w.GetHeadCommit() - w = nil - w.GetHeadCommit() -} - -func TestWebHookPayload_GetInstallation(tt *testing.T) { - w := &WebHookPayload{} - w.GetInstallation() - w = nil - w.GetInstallation() -} - -func TestWebHookPayload_GetOrganization(tt *testing.T) { - w := &WebHookPayload{} - w.GetOrganization() - w = nil - w.GetOrganization() -} - -func TestWebHookPayload_GetPusher(tt *testing.T) { - w := &WebHookPayload{} - w.GetPusher() - w = nil - w.GetPusher() -} - -func TestWebHookPayload_GetRef(tt *testing.T) { - var zeroValue string - w := &WebHookPayload{Ref: &zeroValue} - w.GetRef() - w = &WebHookPayload{} - w.GetRef() - w = nil - w.GetRef() -} - -func TestWebHookPayload_GetRepo(tt *testing.T) { - w := &WebHookPayload{} - w.GetRepo() - w = nil - w.GetRepo() -} - -func TestWebHookPayload_GetSender(tt *testing.T) { - w := &WebHookPayload{} - w.GetSender() - w = nil - w.GetSender() -} - func TestWeeklyCommitActivity_GetTotal(tt *testing.T) { var zeroValue int w := &WeeklyCommitActivity{Total: &zeroValue} diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index 8ebc11cb9d6..5c971f18894 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -1817,55 +1817,6 @@ func TestUserStats_String(t *testing.T) { } } -func TestWebHookAuthor_String(t *testing.T) { - v := WebHookAuthor{ - Email: String(""), - Name: String(""), - Username: String(""), - } - want := `github.WebHookAuthor{Email:"", Name:"", Username:""}` - if got := v.String(); got != want { - t.Errorf("WebHookAuthor.String = %v, want %v", got, want) - } -} - -func TestWebHookCommit_String(t *testing.T) { - v := WebHookCommit{ - Author: &WebHookAuthor{}, - Committer: &WebHookAuthor{}, - Distinct: Bool(false), - ID: String(""), - Message: String(""), - } - want := `github.WebHookCommit{Author:github.WebHookAuthor{}, Committer:github.WebHookAuthor{}, Distinct:false, ID:"", Message:""}` - if got := v.String(); got != want { - t.Errorf("WebHookCommit.String = %v, want %v", got, want) - } -} - -func TestWebHookPayload_String(t *testing.T) { - v := WebHookPayload{ - Action: String(""), - After: String(""), - Before: String(""), - Compare: String(""), - Created: Bool(false), - Deleted: Bool(false), - Forced: Bool(false), - HeadCommit: &WebHookCommit{}, - Installation: &Installation{}, - Organization: &Organization{}, - Pusher: &User{}, - Ref: String(""), - Repo: &Repository{}, - Sender: &User{}, - } - want := `github.WebHookPayload{Action:"", After:"", Before:"", Compare:"", Created:false, Deleted:false, Forced:false, HeadCommit:github.WebHookCommit{}, Installation:github.Installation{}, Organization:github.Organization{}, Pusher:github.User{}, Ref:"", Repo:github.Repository{}, Sender:github.User{}}` - if got := v.String(); got != want { - t.Errorf("WebHookPayload.String = %v, want %v", got, want) - } -} - func TestWeeklyCommitActivity_String(t *testing.T) { v := WeeklyCommitActivity{ Total: Int(0), diff --git a/github/repos_hooks.go b/github/repos_hooks.go index 6afec860391..c6f3d2e92a9 100644 --- a/github/repos_hooks.go +++ b/github/repos_hooks.go @@ -11,6 +11,7 @@ import ( "time" ) +// Deprecated: Please use PushEvent instead. // WebHookPayload represents the data that is received from GitHub when a push // event hook is triggered. The format of these payloads pre-date most of the // GitHub v3 API, so there are lots of minor incompatibilities with the types @@ -18,57 +19,17 @@ import ( // here to account for these differences. // // GitHub API docs: https://help.github.com/articles/post-receive-hooks -type WebHookPayload struct { - Action *string `json:"action,omitempty"` - After *string `json:"after,omitempty"` - Before *string `json:"before,omitempty"` - Commits []*WebHookCommit `json:"commits,omitempty"` - Compare *string `json:"compare,omitempty"` - Created *bool `json:"created,omitempty"` - Deleted *bool `json:"deleted,omitempty"` - Forced *bool `json:"forced,omitempty"` - HeadCommit *WebHookCommit `json:"head_commit,omitempty"` - Installation *Installation `json:"installation,omitempty"` - Organization *Organization `json:"organization,omitempty"` - Pusher *User `json:"pusher,omitempty"` - Ref *string `json:"ref,omitempty"` - Repo *Repository `json:"repository,omitempty"` - Sender *User `json:"sender,omitempty"` -} - -func (w WebHookPayload) String() string { - return Stringify(w) -} +type WebHookPayload = PushEvent +// Deprecated: Please use HeadCommit instead. // WebHookCommit represents the commit variant we receive from GitHub in a // WebHookPayload. -type WebHookCommit struct { - Added []string `json:"added,omitempty"` - Author *WebHookAuthor `json:"author,omitempty"` - Committer *WebHookAuthor `json:"committer,omitempty"` - Distinct *bool `json:"distinct,omitempty"` - ID *string `json:"id,omitempty"` - Message *string `json:"message,omitempty"` - Modified []string `json:"modified,omitempty"` - Removed []string `json:"removed,omitempty"` - Timestamp *time.Time `json:"timestamp,omitempty"` -} - -func (w WebHookCommit) String() string { - return Stringify(w) -} +type WebHookCommit = HeadCommit +// Deprecated: Please use CommitAuthor instead. // WebHookAuthor represents the author or committer of a commit, as specified // in a WebHookCommit. The commit author may not correspond to a GitHub User. -type WebHookAuthor struct { - Email *string `json:"email,omitempty"` - Name *string `json:"name,omitempty"` - Username *string `json:"username,omitempty"` -} - -func (w WebHookAuthor) String() string { - return Stringify(w) -} +type WebHookAuthor = CommitAuthor // Hook represents a GitHub (web and service) hook for a repository. type Hook struct { diff --git a/github/strings_test.go b/github/strings_test.go index 83cb231bbdd..10074f08bdf 100644 --- a/github/strings_test.go +++ b/github/strings_test.go @@ -127,9 +127,9 @@ func TestString(t *testing.T) { {TreeEntry{SHA: String("s")}, `github.TreeEntry{SHA:"s"}`}, {Tree{SHA: String("s")}, `github.Tree{SHA:"s"}`}, {User{ID: Int64(1)}, `github.User{ID:1}`}, - {WebHookAuthor{Name: String("n")}, `github.WebHookAuthor{Name:"n"}`}, - {WebHookCommit{ID: String("1")}, `github.WebHookCommit{ID:"1"}`}, - {WebHookPayload{Ref: String("r")}, `github.WebHookPayload{Ref:"r"}`}, + {WebHookAuthor{Name: String("n")}, `github.CommitAuthor{Name:"n"}`}, + {WebHookCommit{ID: String("1")}, `github.HeadCommit{ID:"1"}`}, + {WebHookPayload{Ref: String("r")}, `github.PushEvent{Ref:"r"}`}, } for i, tt := range tests { From 6b25fb9a89a98487931add42d95e147a64660641 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Fri, 6 Aug 2021 15:42:33 -0400 Subject: [PATCH 2/5] Add missing fields --- github/event_types.go | 2 ++ github/github-accessors.go | 16 ++++++++++++++++ github/github-accessors_test.go | 17 +++++++++++++++++ github/github-stringify_test.go | 4 +++- 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/github/event_types.go b/github/event_types.go index f99a1296a09..d0119becd30 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -785,6 +785,7 @@ type PushEvent struct { DistinctSize *int `json:"distinct_size,omitempty"` // The following fields are only populated by Webhook events. + Action *string `json:"action,omitempty"` After *string `json:"after,omitempty"` Created *bool `json:"created,omitempty"` Deleted *bool `json:"deleted,omitempty"` @@ -796,6 +797,7 @@ type PushEvent struct { Pusher *User `json:"pusher,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + Organization *Organization `json:"organization,omitempty"` } func (p PushEvent) String() string { diff --git a/github/github-accessors.go b/github/github-accessors.go index e75851e2328..a4d85b793d6 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -11732,6 +11732,14 @@ func (p *PunchCard) GetHour() int { return *p.Hour } +// GetAction returns the Action field if it's non-nil, zero value otherwise. +func (p *PushEvent) GetAction() string { + if p == nil || p.Action == nil { + return "" + } + return *p.Action +} + // GetAfter returns the After field if it's non-nil, zero value otherwise. func (p *PushEvent) GetAfter() string { if p == nil || p.After == nil { @@ -11820,6 +11828,14 @@ func (p *PushEvent) GetInstallation() *Installation { return p.Installation } +// GetOrganization returns the Organization field. +func (p *PushEvent) GetOrganization() *Organization { + if p == nil { + return nil + } + return p.Organization +} + // GetPusher returns the Pusher field. func (p *PushEvent) GetPusher() *User { if p == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index e671531a2a0..8e017fc8a1b 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -13646,6 +13646,16 @@ func TestPunchCard_GetHour(tt *testing.T) { p.GetHour() } +func TestPushEvent_GetAction(tt *testing.T) { + var zeroValue string + p := &PushEvent{Action: &zeroValue} + p.GetAction() + p = &PushEvent{} + p.GetAction() + p = nil + p.GetAction() +} + func TestPushEvent_GetAfter(tt *testing.T) { var zeroValue string p := &PushEvent{After: &zeroValue} @@ -13750,6 +13760,13 @@ func TestPushEvent_GetInstallation(tt *testing.T) { p.GetInstallation() } +func TestPushEvent_GetOrganization(tt *testing.T) { + p := &PushEvent{} + p.GetOrganization() + p = nil + p.GetOrganization() +} + func TestPushEvent_GetPusher(tt *testing.T) { p := &PushEvent{} p.GetPusher() diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index 5c971f18894..97c14576fca 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -1259,6 +1259,7 @@ func TestPushEvent_String(t *testing.T) { Size: Int(0), Before: String(""), DistinctSize: Int(0), + Action: String(""), After: String(""), Created: Bool(false), Deleted: Bool(false), @@ -1270,8 +1271,9 @@ func TestPushEvent_String(t *testing.T) { Pusher: &User{}, Sender: &User{}, Installation: &Installation{}, + Organization: &Organization{}, } - want := `github.PushEvent{PushID:0, Head:"", Ref:"", Size:0, Before:"", DistinctSize:0, After:"", Created:false, Deleted:false, Forced:false, BaseRef:"", Compare:"", Repo:github.PushEventRepository{}, HeadCommit:github.HeadCommit{}, Pusher:github.User{}, Sender:github.User{}, Installation:github.Installation{}}` + want := `github.PushEvent{PushID:0, Head:"", Ref:"", Size:0, Before:"", DistinctSize:0, Action:"", After:"", Created:false, Deleted:false, Forced:false, BaseRef:"", Compare:"", Repo:github.PushEventRepository{}, HeadCommit:github.HeadCommit{}, Pusher:github.User{}, Sender:github.User{}, Installation:github.Installation{}, Organization:github.Organization{}}` if got := v.String(); got != want { t.Errorf("PushEvent.String = %v, want %v", got, want) } From 7cb21ea26b2467ac2542e490a663c2bbe1afeaa0 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Mon, 21 Mar 2022 08:51:12 -0400 Subject: [PATCH 3/5] Update tests --- github/repos_hooks_test.go | 44 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/github/repos_hooks_test.go b/github/repos_hooks_test.go index 3137bf4937d..50dad9c236c 100644 --- a/github/repos_hooks_test.go +++ b/github/repos_hooks_test.go @@ -316,14 +316,14 @@ func TestBranchWebHookPayload_Marshal(t *testing.T) { { Added: []string{"1", "2", "3"}, Author: &WebHookAuthor{ - Email: String("abc@gmail.com"), - Name: String("abc"), - Username: String("abc_12"), + Email: String("abc@gmail.com"), + Name: String("abc"), + Login: String("abc_12"), }, Committer: &WebHookAuthor{ - Email: String("abc@gmail.com"), - Name: String("abc"), - Username: String("abc_12"), + Email: String("abc@gmail.com"), + Name: String("abc"), + Login: String("abc_12"), }, ID: String("1"), Message: String("WebHookCommit"), @@ -337,14 +337,14 @@ func TestBranchWebHookPayload_Marshal(t *testing.T) { HeadCommit: &WebHookCommit{ Added: []string{"1", "2", "3"}, Author: &WebHookAuthor{ - Email: String("abc@gmail.com"), - Name: String("abc"), - Username: String("abc_12"), + Email: String("abc@gmail.com"), + Name: String("abc"), + Login: String("abc_12"), }, Committer: &WebHookAuthor{ - Email: String("abc@gmail.com"), - Name: String("abc"), - Username: String("abc_12"), + Email: String("abc@gmail.com"), + Name: String("abc"), + Login: String("abc_12"), }, ID: String("1"), Message: String("WebHookCommit"), @@ -361,7 +361,7 @@ func TestBranchWebHookPayload_Marshal(t *testing.T) { Login: String("rd@yahoo.com"), ID: Int64(112), }, - Repo: &Repository{ + Repo: &PushEventRepository{ ID: Int64(321), NodeID: String("node_321"), }, @@ -441,9 +441,9 @@ func TestBranchWebHookAuthor_Marshal(t *testing.T) { testJSONMarshal(t, &WebHookAuthor{}, "{}") v := &WebHookAuthor{ - Email: String("abc@gmail.com"), - Name: String("abc"), - Username: String("abc_12"), + Email: String("abc@gmail.com"), + Name: String("abc"), + Login: String("abc_12"), } want := `{ @@ -461,14 +461,14 @@ func TestBranchWebHookCommit_Marshal(t *testing.T) { v := &WebHookCommit{ Added: []string{"1", "2", "3"}, Author: &WebHookAuthor{ - Email: String("abc@gmail.com"), - Name: String("abc"), - Username: String("abc_12"), + Email: String("abc@gmail.com"), + Name: String("abc"), + Login: String("abc_12"), }, Committer: &WebHookAuthor{ - Email: String("abc@gmail.com"), - Name: String("abc"), - Username: String("abc_12"), + Email: String("abc@gmail.com"), + Name: String("abc"), + Login: String("abc_12"), }, ID: String("1"), Message: String("WebHookCommit"), From a0403c0d4b9a21bfed166b0ac27b9fa2c8d68206 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Mon, 21 Mar 2022 08:57:20 -0400 Subject: [PATCH 4/5] Add breaking api change comment --- github/repos_hooks.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/github/repos_hooks.go b/github/repos_hooks.go index c6f3d2e92a9..146f8c53da6 100644 --- a/github/repos_hooks.go +++ b/github/repos_hooks.go @@ -29,6 +29,8 @@ type WebHookCommit = HeadCommit // Deprecated: Please use CommitAuthor instead. // WebHookAuthor represents the author or committer of a commit, as specified // in a WebHookCommit. The commit author may not correspond to a GitHub User. +// +// NOTE Breaking API change: the `Username` field is now called `Login`. type WebHookAuthor = CommitAuthor // Hook represents a GitHub (web and service) hook for a repository. From b82aabad4a1e5c6bccfd379e26346df3d3f72bae Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Fri, 25 Mar 2022 18:31:10 -0400 Subject: [PATCH 5/5] Address review feedback --- github/repos_hooks.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/github/repos_hooks.go b/github/repos_hooks.go index 146f8c53da6..61c85219935 100644 --- a/github/repos_hooks.go +++ b/github/repos_hooks.go @@ -11,7 +11,6 @@ import ( "time" ) -// Deprecated: Please use PushEvent instead. // WebHookPayload represents the data that is received from GitHub when a push // event hook is triggered. The format of these payloads pre-date most of the // GitHub v3 API, so there are lots of minor incompatibilities with the types @@ -19,17 +18,20 @@ import ( // here to account for these differences. // // GitHub API docs: https://help.github.com/articles/post-receive-hooks +// +// Deprecated: Please use PushEvent instead. type WebHookPayload = PushEvent -// Deprecated: Please use HeadCommit instead. // WebHookCommit represents the commit variant we receive from GitHub in a // WebHookPayload. +// +// Deprecated: Please use HeadCommit instead. type WebHookCommit = HeadCommit -// Deprecated: Please use CommitAuthor instead. // WebHookAuthor represents the author or committer of a commit, as specified // in a WebHookCommit. The commit author may not correspond to a GitHub User. // +// Deprecated: Please use CommitAuthor instead. // NOTE Breaking API change: the `Username` field is now called `Login`. type WebHookAuthor = CommitAuthor