From 879d435df00c710558a6d5d1600025dc729cc115 Mon Sep 17 00:00:00 2001 From: Parker Moore <237985+parkr@users.noreply.github.com> Date: Thu, 23 Jun 2022 05:39:27 +0000 Subject: [PATCH] IssuesService.Edit: add state_reason state_reason can be 'completed' or 'not_planned'. --- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ github/issues.go | 16 +++++++++------- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 0092c588407..da146bcbf23 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -7630,6 +7630,14 @@ func (i *IssueRequest) GetState() string { return *i.State } +// GetStateReason returns the StateReason field if it's non-nil, zero value otherwise. +func (i *IssueRequest) 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 *IssueRequest) GetTitle() string { if i == nil || i.Title == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index bf5008f53a2..5d30ec960a3 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -8938,6 +8938,16 @@ func TestIssueRequest_GetState(tt *testing.T) { i.GetState() } +func TestIssueRequest_GetStateReason(tt *testing.T) { + var zeroValue string + i := &IssueRequest{StateReason: &zeroValue} + i.GetStateReason() + i = &IssueRequest{} + i.GetStateReason() + i = nil + i.GetStateReason() +} + func TestIssueRequest_GetTitle(tt *testing.T) { var zeroValue string i := &IssueRequest{Title: &zeroValue} diff --git a/github/issues.go b/github/issues.go index 12488f9815e..351ec09cc4f 100644 --- a/github/issues.go +++ b/github/issues.go @@ -77,13 +77,15 @@ func (i Issue) IsPullRequest() bool { // It is separate from Issue above because otherwise Labels // and Assignee fail to serialize to the correct JSON. type IssueRequest struct { - Title *string `json:"title,omitempty"` - Body *string `json:"body,omitempty"` - Labels *[]string `json:"labels,omitempty"` - Assignee *string `json:"assignee,omitempty"` - State *string `json:"state,omitempty"` - Milestone *int `json:"milestone,omitempty"` - Assignees *[]string `json:"assignees,omitempty"` + Title *string `json:"title,omitempty"` + Body *string `json:"body,omitempty"` + Labels *[]string `json:"labels,omitempty"` + Assignee *string `json:"assignee,omitempty"` + State *string `json:"state,omitempty"` + // StateReason can be 'completed' or 'not_planned'. + StateReason *string `json:"state_reason,omitempty"` + Milestone *int `json:"milestone,omitempty"` + Assignees *[]string `json:"assignees,omitempty"` } // IssueListOptions specifies the optional parameters to the IssuesService.List