From aa2932f79e21e90681befedacb604156075938f5 Mon Sep 17 00:00:00 2001 From: ganeshkumarsv Date: Tue, 29 Nov 2022 13:44:45 -0500 Subject: [PATCH 1/4] adding new field state_reason to issues --- github/issues.go | 1 + 1 file changed, 1 insertion(+) diff --git a/github/issues.go b/github/issues.go index 351ec09cc4..0349277586 100644 --- a/github/issues.go +++ b/github/issues.go @@ -28,6 +28,7 @@ type Issue struct { ID *int64 `json:"id,omitempty"` Number *int `json:"number,omitempty"` State *string `json:"state,omitempty"` + StateReason *string `json:"state_reason,omitempty"` Locked *bool `json:"locked,omitempty"` Title *string `json:"title,omitempty"` Body *string `json:"body,omitempty"` From d003203163e1a100b1d3af7467bac9276e253abe Mon Sep 17 00:00:00 2001 From: ganeshkumarsv Date: Tue, 29 Nov 2022 13:46:42 -0500 Subject: [PATCH 2/4] adding gen accessors --- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ github/github-stringify_test.go | 3 ++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 33de4b7e6a..c348e1a3b5 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -7470,6 +7470,14 @@ func (i *Issue) GetState() string { return *i.State } +// GetStateReason returns the StateReason field if it's non-nil, zero value otherwise. +func (i *Issue) GetStateReason() string { + if i == nil || i.StateReason == nil { + return "" + } + return *i.StateReason +} + // GetTitle returns the Title field if it's non-nil, zero value otherwise. func (i *Issue) GetTitle() string { if i == nil || i.Title == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index ecc0d7611b..05fa1961a1 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -8780,6 +8780,16 @@ func TestIssue_GetState(tt *testing.T) { i.GetState() } +func TestIssue_GetStateReason(tt *testing.T) { + var zeroValue string + i := &Issue{StateReason: &zeroValue} + i.GetStateReason() + i = &Issue{} + i.GetStateReason() + i = nil + i.GetStateReason() +} + func TestIssue_GetTitle(tt *testing.T) { var zeroValue string i := &Issue{Title: &zeroValue} diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index b83ff2373d..d4093a0921 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -713,6 +713,7 @@ func TestIssue_String(t *testing.T) { ID: Int64(0), Number: Int(0), State: String(""), + StateReason: String(""), Locked: Bool(false), Title: String(""), Body: String(""), @@ -734,7 +735,7 @@ func TestIssue_String(t *testing.T) { NodeID: String(""), ActiveLockReason: String(""), } - want := `github.Issue{ID:0, Number:0, State:"", Locked:false, Title:"", Body:"", AuthorAssociation:"", User:github.User{}, Assignee:github.User{}, Comments:0, ClosedBy:github.User{}, URL:"", HTMLURL:"", CommentsURL:"", EventsURL:"", LabelsURL:"", RepositoryURL:"", Milestone:github.Milestone{}, PullRequestLinks:github.PullRequestLinks{}, Repository:github.Repository{}, Reactions:github.Reactions{}, NodeID:"", ActiveLockReason:""}` + want := `github.Issue{ID:0, Number:0, State:"", StateReason:"", Locked:false, Title:"", Body:"", AuthorAssociation:"", User:github.User{}, Assignee:github.User{}, Comments:0, ClosedBy:github.User{}, URL:"", HTMLURL:"", CommentsURL:"", EventsURL:"", LabelsURL:"", RepositoryURL:"", Milestone:github.Milestone{}, PullRequestLinks:github.PullRequestLinks{}, Repository:github.Repository{}, Reactions:github.Reactions{}, NodeID:"", ActiveLockReason:""}` if got := v.String(); got != want { t.Errorf("Issue.String = %v, want %v", got, want) } From 5bd7c232c42560e2cc1853861fc88eadafc261f3 Mon Sep 17 00:00:00 2001 From: ganeshkumarsv <53483484+ganeshkumarsv@users.noreply.github.com> Date: Tue, 29 Nov 2022 14:39:56 -0500 Subject: [PATCH 3/4] Update github/issues.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/issues.go | 1 + 1 file changed, 1 insertion(+) diff --git a/github/issues.go b/github/issues.go index 0349277586..11f431ef6a 100644 --- a/github/issues.go +++ b/github/issues.go @@ -28,6 +28,7 @@ type Issue struct { ID *int64 `json:"id,omitempty"` Number *int `json:"number,omitempty"` State *string `json:"state,omitempty"` + // StateReason can be one of: "completed", "not_planned", "reopened". StateReason *string `json:"state_reason,omitempty"` Locked *bool `json:"locked,omitempty"` Title *string `json:"title,omitempty"` From d8540d11a918ca073f6cdd23ce58afb00c81d504 Mon Sep 17 00:00:00 2001 From: ganeshkumarsv Date: Tue, 29 Nov 2022 14:42:24 -0500 Subject: [PATCH 4/4] go fmt --- github/issues.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/github/issues.go b/github/issues.go index 11f431ef6a..571a721170 100644 --- a/github/issues.go +++ b/github/issues.go @@ -25,9 +25,9 @@ type IssuesService service // this is an issue, and if PullRequestLinks is not nil, this is a pull request. // The IsPullRequest helper method can be used to check that. type Issue struct { - ID *int64 `json:"id,omitempty"` - Number *int `json:"number,omitempty"` - State *string `json:"state,omitempty"` + ID *int64 `json:"id,omitempty"` + Number *int `json:"number,omitempty"` + State *string `json:"state,omitempty"` // StateReason can be one of: "completed", "not_planned", "reopened". StateReason *string `json:"state_reason,omitempty"` Locked *bool `json:"locked,omitempty"`