diff --git a/github/github-accessors.go b/github/github-accessors.go index c90680b9c91..d39473a0f24 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -6108,6 +6108,14 @@ func (i *IssueImportResponse) GetURL() string { return *i.URL } +// GetDirection returns the Direction field if it's non-nil, zero value otherwise. +func (i *IssueListCommentsOptions) GetDirection() string { + if i == nil || i.Direction == nil { + return "" + } + return *i.Direction +} + // GetSince returns the Since field if it's non-nil, zero value otherwise. func (i *IssueListCommentsOptions) GetSince() time.Time { if i == nil || i.Since == nil { @@ -6116,6 +6124,14 @@ func (i *IssueListCommentsOptions) GetSince() time.Time { return *i.Since } +// GetSort returns the Sort field if it's non-nil, zero value otherwise. +func (i *IssueListCommentsOptions) GetSort() string { + if i == nil || i.Sort == nil { + return "" + } + return *i.Sort +} + // GetAssignee returns the Assignee field if it's non-nil, zero value otherwise. func (i *IssueRequest) GetAssignee() string { if i == nil || i.Assignee == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 834a8988c9c..b3d31306ed5 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -7186,6 +7186,16 @@ func TestIssueImportResponse_GetURL(tt *testing.T) { i.GetURL() } +func TestIssueListCommentsOptions_GetDirection(tt *testing.T) { + var zeroValue string + i := &IssueListCommentsOptions{Direction: &zeroValue} + i.GetDirection() + i = &IssueListCommentsOptions{} + i.GetDirection() + i = nil + i.GetDirection() +} + func TestIssueListCommentsOptions_GetSince(tt *testing.T) { var zeroValue time.Time i := &IssueListCommentsOptions{Since: &zeroValue} @@ -7196,6 +7206,16 @@ func TestIssueListCommentsOptions_GetSince(tt *testing.T) { i.GetSince() } +func TestIssueListCommentsOptions_GetSort(tt *testing.T) { + var zeroValue string + i := &IssueListCommentsOptions{Sort: &zeroValue} + i.GetSort() + i = &IssueListCommentsOptions{} + i.GetSort() + i = nil + i.GetSort() +} + func TestIssueRequest_GetAssignee(tt *testing.T) { var zeroValue string i := &IssueRequest{Assignee: &zeroValue} diff --git a/github/issues_comments.go b/github/issues_comments.go index 18371639c34..6dd6d13287c 100644 --- a/github/issues_comments.go +++ b/github/issues_comments.go @@ -35,6 +35,12 @@ func (i IssueComment) String() string { // IssueListCommentsOptions specifies the optional parameters to the // IssuesService.ListComments method. type IssueListCommentsOptions struct { + // Sort specifies how to sort comments. Possible values are: created, updated. + Sort *string `url:"sort,omitempty"` + + // Direction in which to sort comments. Possible values are: asc, desc. + Direction *string `url:"direction,omitempty"` + // Since filters comments by time. Since *time.Time `url:"since,omitempty"` diff --git a/github/issues_comments_test.go b/github/issues_comments_test.go index aeff1cdfd2f..90bfc7c0fd9 100644 --- a/github/issues_comments_test.go +++ b/github/issues_comments_test.go @@ -23,14 +23,18 @@ func TestIssuesService_ListComments_allIssues(t *testing.T) { testMethod(t, r, "GET") testHeader(t, r, "Accept", mediaTypeReactionsPreview) testFormValues(t, r, values{ - "since": "2002-02-10T15:30:00Z", - "page": "2", + "sort": "updated", + "direction": "desc", + "since": "2002-02-10T15:30:00Z", + "page": "2", }) fmt.Fprint(w, `[{"id":1}]`) }) since := time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC) opt := &IssueListCommentsOptions{ + Sort: String("updated"), + Direction: String("desc"), Since: &since, ListOptions: ListOptions{Page: 2}, }