diff --git a/github/event_types.go b/github/event_types.go index 6ff1eb84851..327fc561662 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -388,11 +388,12 @@ type GollumEvent struct { // EditChange represents the changes when an issue, pull request, comment, // or repository has been edited. type EditChange struct { - Title *EditTitle `json:"title,omitempty"` - Body *EditBody `json:"body,omitempty"` - Base *EditBase `json:"base,omitempty"` - Repo *EditRepo `json:"repository,omitempty"` - Owner *EditOwner `json:"owner,omitempty"` + Title *EditTitle `json:"title,omitempty"` + Body *EditBody `json:"body,omitempty"` + Base *EditBase `json:"base,omitempty"` + Repo *EditRepo `json:"repository,omitempty"` + Owner *EditOwner `json:"owner,omitempty"` + DefaultBranch *EditDefaultBranch `json:"default_branch,omitempty"` } // EditTitle represents a pull-request title change. @@ -442,6 +443,11 @@ type EditSHA struct { From *string `json:"from,omitempty"` } +// EditDefaultBranch represents a change of repository's default branch name. +type EditDefaultBranch struct { + From *string `json:"from,omitempty"` +} + // ProjectChange represents the changes when a project has been edited. type ProjectChange struct { Name *ProjectName `json:"name,omitempty"` diff --git a/github/github-accessors.go b/github/github-accessors.go index 536ce5a8407..541be64a8de 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -6678,6 +6678,14 @@ func (e *EditChange) GetBody() *EditBody { return e.Body } +// GetDefaultBranch returns the DefaultBranch field. +func (e *EditChange) GetDefaultBranch() *EditDefaultBranch { + if e == nil { + return nil + } + return e.DefaultBranch +} + // GetOwner returns the Owner field. func (e *EditChange) GetOwner() *EditOwner { if e == nil { @@ -6702,6 +6710,14 @@ func (e *EditChange) GetTitle() *EditTitle { return e.Title } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (e *EditDefaultBranch) GetFrom() string { + if e == nil || e.From == nil { + return "" + } + return *e.From +} + // GetOwnerInfo returns the OwnerInfo field. func (e *EditOwner) GetOwnerInfo() *OwnerInfo { if e == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index abe96ecf98f..49ed8eee086 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -7826,6 +7826,13 @@ func TestEditChange_GetBody(tt *testing.T) { e.GetBody() } +func TestEditChange_GetDefaultBranch(tt *testing.T) { + e := &EditChange{} + e.GetDefaultBranch() + e = nil + e.GetDefaultBranch() +} + func TestEditChange_GetOwner(tt *testing.T) { e := &EditChange{} e.GetOwner() @@ -7847,6 +7854,16 @@ func TestEditChange_GetTitle(tt *testing.T) { e.GetTitle() } +func TestEditDefaultBranch_GetFrom(tt *testing.T) { + var zeroValue string + e := &EditDefaultBranch{From: &zeroValue} + e.GetFrom() + e = &EditDefaultBranch{} + e.GetFrom() + e = nil + e.GetFrom() +} + func TestEditOwner_GetOwnerInfo(tt *testing.T) { e := &EditOwner{} e.GetOwnerInfo()