Repository: google/go-github
Pull request #1857 (2021-04-24 11:48:21)

Revert "Fix: Remove Sort & Direction Fields From IssueListCommentsOptions"
Reverts google/go-github#1584

codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/1857?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#1857](https://codecov.io/gh/google/go-github/pull/1857?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (5d4aed6) into [master](https://codecov.io/gh/google/go-github/commit/b235769d16066e228821a3e0fae66305b49021d6?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (b235769) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/1857/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)](https://codecov.io/gh/google/go-github/pull/1857?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)

```diff
@@           Coverage Diff           @@
##           master    #1857   +/-   ##
=======================================
  Coverage   97.64%   97.64%           
=======================================
  Files         105      105           
  Lines        6764     6764           
=======================================
  Hits         6605     6605           
  Misses         86       86           
  Partials       73       73           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/1857?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/issues\_comments.go](https://codecov.io/gh/google/go-github/pull/1857/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL2lzc3Vlc19jb21tZW50cy5nbw==) | `100.00% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/1857?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/1857?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Last update [b235769...5d4aed6](https://codecov.io/gh/google/go-github/pull/1857?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).

gmlewis: @tamalsaha or @nightlark - if you could please review and approve this PR, that would be helpful.
tamalsaha: Thanks, LGTM!

Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index c90680b9..d39473a0 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/issues_comments.go b/github/issues_comments.go
index 18371639..6dd6d132 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"`
 


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 834a8988..b3d31306 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_test.go b/github/issues_comments_test.go
index aeff1cdf..90bfc7c0 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},
 	}