From 181d685cc8982d084708abd10b1d965e3ed27afb Mon Sep 17 00:00:00 2001 From: maishivamhoo123 Date: Mon, 9 Feb 2026 20:19:13 +0530 Subject: [PATCH 1/7] fix: add pagination support for IssuesService list methods --- github/github-iterators.go | 12 ++++-------- github/github-iterators_test.go | 8 ++++---- github/issues.go | 6 ------ github/issues_test.go | 8 +------- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/github/github-iterators.go b/github/github-iterators.go index 691b5ee10ce..f439c4db99b 100644 --- a/github/github-iterators.go +++ b/github/github-iterators.go @@ -1312,10 +1312,9 @@ func (s *IssuesService) ListIter(ctx context.Context, all bool, opts *IssueListO } } - if resp.Cursor == "" && resp.NextPage == 0 { + if resp.NextPage == 0 { break } - opts.ListCursorOptions.Cursor = resp.Cursor opts.ListOptions.Page = resp.NextPage } } @@ -1375,10 +1374,9 @@ func (s *IssuesService) ListByOrgIter(ctx context.Context, org string, opts *Iss } } - if resp.Cursor == "" && resp.NextPage == 0 { + if resp.NextPage == 0 { break } - opts.ListCursorOptions.Cursor = resp.Cursor opts.ListOptions.Page = resp.NextPage } } @@ -1407,10 +1405,9 @@ func (s *IssuesService) ListByRepoIter(ctx context.Context, owner string, repo s } } - if resp.Cursor == "" && resp.NextPage == 0 { + if resp.NextPage == 0 { break } - opts.ListCursorOptions.Cursor = resp.Cursor opts.ListOptions.Page = resp.NextPage } } @@ -3736,10 +3733,9 @@ func (s *SubIssueService) ListByIssueIter(ctx context.Context, owner string, rep } } - if resp.Cursor == "" && resp.NextPage == 0 { + if resp.NextPage == 0 { break } - opts.ListCursorOptions.Cursor = resp.Cursor opts.ListOptions.Page = resp.NextPage } } diff --git a/github/github-iterators_test.go b/github/github-iterators_test.go index fa5197ccf22..b4eb99cbbef 100644 --- a/github/github-iterators_test.go +++ b/github/github-iterators_test.go @@ -2975,7 +2975,7 @@ func TestIssuesService_ListIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -3119,7 +3119,7 @@ func TestIssuesService_ListByOrgIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -3191,7 +3191,7 @@ func TestIssuesService_ListByRepoIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -8591,7 +8591,7 @@ func TestSubIssueService_ListByIssueIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) diff --git a/github/issues.go b/github/issues.go index 861c3fa5f90..7a23d34891f 100644 --- a/github/issues.go +++ b/github/issues.go @@ -125,10 +125,7 @@ type IssueListOptions struct { // Since filters issues by time. Since time.Time `url:"since,omitempty"` - ListCursorOptions - // Add ListOptions so offset pagination with integer type "page" query parameter is accepted - // since ListCursorOptions accepts "page" as string only. ListOptions } @@ -245,10 +242,7 @@ type IssueListByRepoOptions struct { // Since filters issues by time. Since time.Time `url:"since,omitempty"` - ListCursorOptions - // Add ListOptions so offset pagination with integer type "page" query parameter is accepted - // since ListCursorOptions accepts "page" as string only. ListOptions } diff --git a/github/issues_test.go b/github/issues_test.go index 53fe46aa81d..8dbee2fbc32 100644 --- a/github/issues_test.go +++ b/github/issues_test.go @@ -31,8 +31,6 @@ func TestIssuesService_List_all(t *testing.T) { "since": "2002-02-10T15:30:00Z", "page": "1", "per_page": "2", - "before": "foo", - "after": "bar", }) fmt.Fprint(w, `[{"number":1}]`) }) @@ -42,7 +40,6 @@ func TestIssuesService_List_all(t *testing.T) { []string{"a", "b"}, "updated", "asc", time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC), - ListCursorOptions{Before: "foo", After: "bar"}, ListOptions{Page: 1, PerPage: 2}, } ctx := t.Context() @@ -160,8 +157,6 @@ func TestIssuesService_ListByRepo(t *testing.T) { "direction": "asc", "since": "2002-02-10T15:30:00Z", "per_page": "1", - "before": "foo", - "after": "bar", }) fmt.Fprint(w, `[{"number":1}]`) }) @@ -171,8 +166,7 @@ func TestIssuesService_ListByRepo(t *testing.T) { []string{"a", "b"}, "updated", "asc", time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC), - ListCursorOptions{PerPage: 1, Before: "foo", After: "bar"}, - ListOptions{0, 0}, + ListOptions{PerPage: 1}, } ctx := t.Context() issues, _, err := client.Issues.ListByRepo(ctx, "o", "r", opt) From fc21140cb6eb301efcbce2be52e325de84b5ad28 Mon Sep 17 00:00:00 2001 From: maishivamhoo123 Date: Tue, 10 Feb 2026 17:11:03 +0530 Subject: [PATCH 2/7] fix!: refactor IssueListOptions and restore cursor pagination --- .golangci.yml | 5 --- github/github-accessors.go | 40 ++++++++++++++++++++++++ github/github-accessors_test.go | 55 +++++++++++++++++++++++++++++++++ github/github-iterators.go | 4 +-- github/github-iterators_test.go | 2 +- github/issues.go | 14 ++++----- github/issues_test.go | 31 +++++++++++++------ 7 files changed, 126 insertions(+), 25 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 36483d72a03..874312352c1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -287,11 +287,6 @@ linters: - IssueListByRepoOptions.Sort # TODO: Issues - IssueListByRepoOptions.Sort # TODO: Issues - IssueListByRepoOptions.State # TODO: Issues - - IssueListOptions.Direction # TODO: Issues - - IssueListOptions.Filter # TODO: Issues - - IssueListOptions.Since # TODO: Issues - - IssueListOptions.Sort # TODO: Issues - - IssueListOptions.State # TODO: Issues - IssueRequest.Assignees # TODO: Issues - IssueRequest.Labels # TODO: Issues - License.Conditions # TODO: Licenses diff --git a/github/github-accessors.go b/github/github-accessors.go index 27c88d51c39..00082d50ba6 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -13774,6 +13774,46 @@ func (i *IssueListCommentsOptions) GetSort() string { return *i.Sort } +// GetDirection returns the Direction field if it's non-nil, zero value otherwise. +func (i *IssueListOptions) GetDirection() string { + if i == nil || i.Direction == nil { + return "" + } + return *i.Direction +} + +// GetFilter returns the Filter field if it's non-nil, zero value otherwise. +func (i *IssueListOptions) GetFilter() string { + if i == nil || i.Filter == nil { + return "" + } + return *i.Filter +} + +// GetSince returns the Since field if it's non-nil, zero value otherwise. +func (i *IssueListOptions) GetSince() time.Time { + if i == nil || i.Since == nil { + return time.Time{} + } + return *i.Since +} + +// GetSort returns the Sort field if it's non-nil, zero value otherwise. +func (i *IssueListOptions) GetSort() string { + if i == nil || i.Sort == nil { + return "" + } + return *i.Sort +} + +// GetState returns the State field if it's non-nil, zero value otherwise. +func (i *IssueListOptions) GetState() string { + if i == nil || i.State == nil { + return "" + } + return *i.State +} + // 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 835f310e0b7..8421fc3a30f 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -17903,6 +17903,61 @@ func TestIssueListCommentsOptions_GetSort(tt *testing.T) { i.GetSort() } +func TestIssueListOptions_GetDirection(tt *testing.T) { + tt.Parallel() + var zeroValue string + i := &IssueListOptions{Direction: &zeroValue} + i.GetDirection() + i = &IssueListOptions{} + i.GetDirection() + i = nil + i.GetDirection() +} + +func TestIssueListOptions_GetFilter(tt *testing.T) { + tt.Parallel() + var zeroValue string + i := &IssueListOptions{Filter: &zeroValue} + i.GetFilter() + i = &IssueListOptions{} + i.GetFilter() + i = nil + i.GetFilter() +} + +func TestIssueListOptions_GetSince(tt *testing.T) { + tt.Parallel() + var zeroValue time.Time + i := &IssueListOptions{Since: &zeroValue} + i.GetSince() + i = &IssueListOptions{} + i.GetSince() + i = nil + i.GetSince() +} + +func TestIssueListOptions_GetSort(tt *testing.T) { + tt.Parallel() + var zeroValue string + i := &IssueListOptions{Sort: &zeroValue} + i.GetSort() + i = &IssueListOptions{} + i.GetSort() + i = nil + i.GetSort() +} + +func TestIssueListOptions_GetState(tt *testing.T) { + tt.Parallel() + var zeroValue string + i := &IssueListOptions{State: &zeroValue} + i.GetState() + i = &IssueListOptions{} + i.GetState() + i = nil + i.GetState() +} + func TestIssueRequest_GetAssignee(tt *testing.T) { tt.Parallel() var zeroValue string diff --git a/github/github-iterators.go b/github/github-iterators.go index f439c4db99b..ec9975a590f 100644 --- a/github/github-iterators.go +++ b/github/github-iterators.go @@ -1405,10 +1405,10 @@ func (s *IssuesService) ListByRepoIter(ctx context.Context, owner string, repo s } } - if resp.NextPage == 0 { + if resp.Cursor == "" { break } - opts.ListOptions.Page = resp.NextPage + opts.ListCursorOptions.Cursor = resp.Cursor } } } diff --git a/github/github-iterators_test.go b/github/github-iterators_test.go index b4eb99cbbef..4cfd52c73b9 100644 --- a/github/github-iterators_test.go +++ b/github/github-iterators_test.go @@ -3191,7 +3191,7 @@ func TestIssuesService_ListByRepoIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) diff --git a/github/issues.go b/github/issues.go index 7a23d34891f..1528c83b648 100644 --- a/github/issues.go +++ b/github/issues.go @@ -105,25 +105,25 @@ type IssueRequest struct { type IssueListOptions struct { // Filter specifies which issues to list. Possible values are: assigned, // created, mentioned, subscribed, all. Default is "assigned". - Filter string `url:"filter,omitempty"` + Filter *string `url:"filter,omitempty"` // State filters issues based on their state. Possible values are: open, // closed, all. Default is "open". - State string `url:"state,omitempty"` + State *string `url:"state,omitempty"` // Labels filters issues based on their label. Labels []string `url:"labels,comma,omitempty"` // Sort specifies how to sort issues. Possible values are: created, updated, // and comments. Default value is "created". - Sort string `url:"sort,omitempty"` + Sort *string `url:"sort,omitempty"` // Direction in which to sort issues. Possible values are: asc, desc. // Default is "desc". - Direction string `url:"direction,omitempty"` + Direction *string `url:"direction,omitempty"` // Since filters issues by time. - Since time.Time `url:"since,omitempty"` + Since *time.Time `url:"since,omitempty"` // Add ListOptions so offset pagination with integer type "page" query parameter is accepted ListOptions @@ -242,8 +242,8 @@ type IssueListByRepoOptions struct { // Since filters issues by time. Since time.Time `url:"since,omitempty"` - // Add ListOptions so offset pagination with integer type "page" query parameter is accepted - ListOptions + // ListCursorOptions specifies the optional parameters for cursor pagination. + ListCursorOptions } // ListByRepo lists the issues for the specified repository. diff --git a/github/issues_test.go b/github/issues_test.go index 8dbee2fbc32..9494f361c94 100644 --- a/github/issues_test.go +++ b/github/issues_test.go @@ -35,12 +35,16 @@ func TestIssuesService_List_all(t *testing.T) { fmt.Fprint(w, `[{"number":1}]`) }) + since := time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC) + opt := &IssueListOptions{ - "all", "closed", - []string{"a", "b"}, - "updated", "asc", - time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC), - ListOptions{Page: 1, PerPage: 2}, + Filter: Ptr("all"), + State: Ptr("closed"), + Labels: []string{"a", "b"}, + Sort: Ptr("updated"), + Direction: Ptr("asc"), + Since: &since, + ListOptions: ListOptions{Page: 1, PerPage: 2}, } ctx := t.Context() issues, _, err := client.Issues.List(ctx, true, opt) @@ -161,13 +165,20 @@ func TestIssuesService_ListByRepo(t *testing.T) { fmt.Fprint(w, `[{"number":1}]`) }) + // IssueListByRepoOptions uses standard strings (not pointers) and ListCursorOptions opt := &IssueListByRepoOptions{ - "*", "closed", "a", "c", "m", - []string{"a", "b"}, - "updated", "asc", - time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC), - ListOptions{PerPage: 1}, + Milestone: "*", + State: "closed", + Assignee: "a", + Creator: "c", + Mentioned: "m", + Labels: []string{"a", "b"}, + Sort: "updated", + Direction: "asc", + Since: time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC), + ListCursorOptions: ListCursorOptions{PerPage: 1}, } + ctx := t.Context() issues, _, err := client.Issues.ListByRepo(ctx, "o", "r", opt) if err != nil { From ab4224b172f4df8c116ccc3ae546caed68aa2a60 Mon Sep 17 00:00:00 2001 From: maishivamhoo123 Date: Tue, 10 Feb 2026 18:30:33 +0530 Subject: [PATCH 3/7] test: inline time.Date in IssueListOptions test --- github/issues_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/github/issues_test.go b/github/issues_test.go index 9494f361c94..430b3e58c77 100644 --- a/github/issues_test.go +++ b/github/issues_test.go @@ -35,15 +35,14 @@ func TestIssuesService_List_all(t *testing.T) { fmt.Fprint(w, `[{"number":1}]`) }) - since := time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC) - + // Reviewer suggestion applied: Ptr() handles the time.Time inline opt := &IssueListOptions{ Filter: Ptr("all"), State: Ptr("closed"), Labels: []string{"a", "b"}, Sort: Ptr("updated"), Direction: Ptr("asc"), - Since: &since, + Since: Ptr(time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)), ListOptions: ListOptions{Page: 1, PerPage: 2}, } ctx := t.Context() From 2b7815a3f8f8ba93715683755d48fcce6b55c115 Mon Sep 17 00:00:00 2001 From: maishivamhoo123 Date: Tue, 10 Feb 2026 22:17:32 +0530 Subject: [PATCH 4/7] test: use shared referenceTime variable per review --- github/github-iterators.go | 9 ++++++--- github/github-iterators_test.go | 6 +++--- github/issues.go | 3 +++ github/issues_test.go | 9 ++++----- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/github/github-iterators.go b/github/github-iterators.go index 0b54cc8409c..b70277dffa6 100644 --- a/github/github-iterators.go +++ b/github/github-iterators.go @@ -1312,9 +1312,10 @@ func (s *IssuesService) ListIter(ctx context.Context, all bool, opts *IssueListO } } - if resp.NextPage == 0 { + if resp.Cursor == "" && resp.NextPage == 0 { break } + opts.ListCursorOptions.Cursor = resp.Cursor opts.ListOptions.Page = resp.NextPage } } @@ -1374,9 +1375,10 @@ func (s *IssuesService) ListByOrgIter(ctx context.Context, org string, opts *Iss } } - if resp.NextPage == 0 { + if resp.Cursor == "" && resp.NextPage == 0 { break } + opts.ListCursorOptions.Cursor = resp.Cursor opts.ListOptions.Page = resp.NextPage } } @@ -3795,9 +3797,10 @@ func (s *SubIssueService) ListByIssueIter(ctx context.Context, owner string, rep } } - if resp.NextPage == 0 { + if resp.Cursor == "" && resp.NextPage == 0 { break } + opts.ListCursorOptions.Cursor = resp.Cursor opts.ListOptions.Page = resp.NextPage } } diff --git a/github/github-iterators_test.go b/github/github-iterators_test.go index 3baf114d923..eba8c44540b 100644 --- a/github/github-iterators_test.go +++ b/github/github-iterators_test.go @@ -2975,7 +2975,7 @@ func TestIssuesService_ListIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -3119,7 +3119,7 @@ func TestIssuesService_ListByOrgIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -8735,7 +8735,7 @@ func TestSubIssueService_ListByIssueIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) diff --git a/github/issues.go b/github/issues.go index 1528c83b648..45a8b2c381f 100644 --- a/github/issues.go +++ b/github/issues.go @@ -125,7 +125,10 @@ type IssueListOptions struct { // Since filters issues by time. Since *time.Time `url:"since,omitempty"` + ListCursorOptions + // Add ListOptions so offset pagination with integer type "page" query parameter is accepted + // since ListCursorOptions accepts "page" as string only. ListOptions } diff --git a/github/issues_test.go b/github/issues_test.go index 430b3e58c77..6a9f5e1e50a 100644 --- a/github/issues_test.go +++ b/github/issues_test.go @@ -28,21 +28,20 @@ func TestIssuesService_List_all(t *testing.T) { "labels": "a,b", "sort": "updated", "direction": "asc", - "since": "2002-02-10T15:30:00Z", + "since": referenceTime.Format(time.RFC3339), "page": "1", "per_page": "2", }) fmt.Fprint(w, `[{"number":1}]`) }) - // Reviewer suggestion applied: Ptr() handles the time.Time inline opt := &IssueListOptions{ Filter: Ptr("all"), State: Ptr("closed"), Labels: []string{"a", "b"}, Sort: Ptr("updated"), Direction: Ptr("asc"), - Since: Ptr(time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)), + Since: Ptr(referenceTime), ListOptions: ListOptions{Page: 1, PerPage: 2}, } ctx := t.Context() @@ -158,7 +157,7 @@ func TestIssuesService_ListByRepo(t *testing.T) { "labels": "a,b", "sort": "updated", "direction": "asc", - "since": "2002-02-10T15:30:00Z", + "since": referenceTime.Format(time.RFC3339), "per_page": "1", }) fmt.Fprint(w, `[{"number":1}]`) @@ -174,7 +173,7 @@ func TestIssuesService_ListByRepo(t *testing.T) { Labels: []string{"a", "b"}, Sort: "updated", Direction: "asc", - Since: time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC), + Since: referenceTime, ListCursorOptions: ListCursorOptions{PerPage: 1}, } From 4a7a3f7ebc4368441dfabb7f388669826d8da5bc Mon Sep 17 00:00:00 2001 From: maishivamhoo123 Date: Tue, 10 Feb 2026 23:37:28 +0530 Subject: [PATCH 5/7] test: removed pointer from IssueListOptions struct --- .golangci.yml | 5 +++ github/github-accessors.go | 40 ------------------------ github/github-accessors_test.go | 55 --------------------------------- github/issues.go | 10 +++--- github/issues_test.go | 10 +++--- 5 files changed, 15 insertions(+), 105 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 874312352c1..af3b5f1aa88 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -287,6 +287,11 @@ linters: - IssueListByRepoOptions.Sort # TODO: Issues - IssueListByRepoOptions.Sort # TODO: Issues - IssueListByRepoOptions.State # TODO: Issues + - IssueListOptions.Direction # TODO: Issues + - IssueListOptions.Filter # TODO: Issues + - IssueListOptions.Since # TODO: Issues + - IssueListOptions.Sort # TODO: Issues + - IssueListOptions.State # TODO: Issues - IssueRequest.Assignees # TODO: Issues - IssueRequest.Labels # TODO: Issues - License.Conditions # TODO: Licenses diff --git a/github/github-accessors.go b/github/github-accessors.go index e2236949b6c..1d79e676c4d 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -13774,46 +13774,6 @@ func (i *IssueListCommentsOptions) GetSort() string { return *i.Sort } -// GetDirection returns the Direction field if it's non-nil, zero value otherwise. -func (i *IssueListOptions) GetDirection() string { - if i == nil || i.Direction == nil { - return "" - } - return *i.Direction -} - -// GetFilter returns the Filter field if it's non-nil, zero value otherwise. -func (i *IssueListOptions) GetFilter() string { - if i == nil || i.Filter == nil { - return "" - } - return *i.Filter -} - -// GetSince returns the Since field if it's non-nil, zero value otherwise. -func (i *IssueListOptions) GetSince() time.Time { - if i == nil || i.Since == nil { - return time.Time{} - } - return *i.Since -} - -// GetSort returns the Sort field if it's non-nil, zero value otherwise. -func (i *IssueListOptions) GetSort() string { - if i == nil || i.Sort == nil { - return "" - } - return *i.Sort -} - -// GetState returns the State field if it's non-nil, zero value otherwise. -func (i *IssueListOptions) GetState() string { - if i == nil || i.State == nil { - return "" - } - return *i.State -} - // 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 2feb67d44d7..49296912c7c 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -17903,61 +17903,6 @@ func TestIssueListCommentsOptions_GetSort(tt *testing.T) { i.GetSort() } -func TestIssueListOptions_GetDirection(tt *testing.T) { - tt.Parallel() - var zeroValue string - i := &IssueListOptions{Direction: &zeroValue} - i.GetDirection() - i = &IssueListOptions{} - i.GetDirection() - i = nil - i.GetDirection() -} - -func TestIssueListOptions_GetFilter(tt *testing.T) { - tt.Parallel() - var zeroValue string - i := &IssueListOptions{Filter: &zeroValue} - i.GetFilter() - i = &IssueListOptions{} - i.GetFilter() - i = nil - i.GetFilter() -} - -func TestIssueListOptions_GetSince(tt *testing.T) { - tt.Parallel() - var zeroValue time.Time - i := &IssueListOptions{Since: &zeroValue} - i.GetSince() - i = &IssueListOptions{} - i.GetSince() - i = nil - i.GetSince() -} - -func TestIssueListOptions_GetSort(tt *testing.T) { - tt.Parallel() - var zeroValue string - i := &IssueListOptions{Sort: &zeroValue} - i.GetSort() - i = &IssueListOptions{} - i.GetSort() - i = nil - i.GetSort() -} - -func TestIssueListOptions_GetState(tt *testing.T) { - tt.Parallel() - var zeroValue string - i := &IssueListOptions{State: &zeroValue} - i.GetState() - i = &IssueListOptions{} - i.GetState() - i = nil - i.GetState() -} - func TestIssueRequest_GetAssignee(tt *testing.T) { tt.Parallel() var zeroValue string diff --git a/github/issues.go b/github/issues.go index 45a8b2c381f..323239b8802 100644 --- a/github/issues.go +++ b/github/issues.go @@ -105,25 +105,25 @@ type IssueRequest struct { type IssueListOptions struct { // Filter specifies which issues to list. Possible values are: assigned, // created, mentioned, subscribed, all. Default is "assigned". - Filter *string `url:"filter,omitempty"` + Filter string `url:"filter,omitempty"` // State filters issues based on their state. Possible values are: open, // closed, all. Default is "open". - State *string `url:"state,omitempty"` + State string `url:"state,omitempty"` // Labels filters issues based on their label. Labels []string `url:"labels,comma,omitempty"` // Sort specifies how to sort issues. Possible values are: created, updated, // and comments. Default value is "created". - Sort *string `url:"sort,omitempty"` + Sort string `url:"sort,omitempty"` // Direction in which to sort issues. Possible values are: asc, desc. // Default is "desc". - Direction *string `url:"direction,omitempty"` + Direction string `url:"direction,omitempty"` // Since filters issues by time. - Since *time.Time `url:"since,omitempty"` + Since time.Time `url:"since,omitempty"` ListCursorOptions diff --git a/github/issues_test.go b/github/issues_test.go index 6a9f5e1e50a..04cdb1c05ad 100644 --- a/github/issues_test.go +++ b/github/issues_test.go @@ -36,12 +36,12 @@ func TestIssuesService_List_all(t *testing.T) { }) opt := &IssueListOptions{ - Filter: Ptr("all"), - State: Ptr("closed"), + Filter: "all", + State: "closed", Labels: []string{"a", "b"}, - Sort: Ptr("updated"), - Direction: Ptr("asc"), - Since: Ptr(referenceTime), + Sort: "updated", + Direction: "asc", + Since: referenceTime, ListOptions: ListOptions{Page: 1, PerPage: 2}, } ctx := t.Context() From be42bdfa6b1c83bd524887fce69faaf39235a7ff Mon Sep 17 00:00:00 2001 From: maishivamhoo123 Date: Wed, 11 Feb 2026 08:49:47 +0530 Subject: [PATCH 6/7] fix: revert pointers and update linter config --- github/github-iterators.go | 12 +++++------- github/github-iterators_test.go | 6 +++--- github/issues.go | 7 ++++--- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/github/github-iterators.go b/github/github-iterators.go index 02530507d94..90a057e63d2 100644 --- a/github/github-iterators.go +++ b/github/github-iterators.go @@ -1312,10 +1312,9 @@ func (s *IssuesService) ListIter(ctx context.Context, all bool, opts *IssueListO } } - if resp.Cursor == "" && resp.NextPage == 0 { + if resp.NextPage == 0 { break } - opts.ListCursorOptions.Cursor = resp.Cursor opts.ListOptions.Page = resp.NextPage } } @@ -1375,10 +1374,9 @@ func (s *IssuesService) ListByOrgIter(ctx context.Context, org string, opts *Iss } } - if resp.Cursor == "" && resp.NextPage == 0 { + if resp.NextPage == 0 { break } - opts.ListCursorOptions.Cursor = resp.Cursor opts.ListOptions.Page = resp.NextPage } } @@ -1407,10 +1405,11 @@ func (s *IssuesService) ListByRepoIter(ctx context.Context, owner string, repo s } } - if resp.Cursor == "" { + if resp.Cursor == "" && resp.NextPage == 0 { break } opts.ListCursorOptions.Cursor = resp.Cursor + opts.ListOptions.Page = resp.NextPage } } } @@ -3766,10 +3765,9 @@ func (s *SubIssueService) ListByIssueIter(ctx context.Context, owner string, rep } } - if resp.Cursor == "" && resp.NextPage == 0 { + if resp.NextPage == 0 { break } - opts.ListCursorOptions.Cursor = resp.Cursor opts.ListOptions.Page = resp.NextPage } } diff --git a/github/github-iterators_test.go b/github/github-iterators_test.go index 73289af8eea..85a0bca6431 100644 --- a/github/github-iterators_test.go +++ b/github/github-iterators_test.go @@ -2975,7 +2975,7 @@ func TestIssuesService_ListIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -3119,7 +3119,7 @@ func TestIssuesService_ListByOrgIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -8663,7 +8663,7 @@ func TestSubIssueService_ListByIssueIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) diff --git a/github/issues.go b/github/issues.go index 323239b8802..95cb13582a4 100644 --- a/github/issues.go +++ b/github/issues.go @@ -125,10 +125,7 @@ type IssueListOptions struct { // Since filters issues by time. Since time.Time `url:"since,omitempty"` - ListCursorOptions - // Add ListOptions so offset pagination with integer type "page" query parameter is accepted - // since ListCursorOptions accepts "page" as string only. ListOptions } @@ -247,6 +244,10 @@ type IssueListByRepoOptions struct { // ListCursorOptions specifies the optional parameters for cursor pagination. ListCursorOptions + + // Add ListOptions so offset pagination with integer type "page" query parameter is accepted + // since ListCursorOptions accepts "page" as string only. + ListOptions } // ListByRepo lists the issues for the specified repository. From 9b0599a430c518af055ea8c0f9362f7a7daa6f8f Mon Sep 17 00:00:00 2001 From: Shivam Kumar <155747305+maishivamhoo123@users.noreply.github.com> Date: Wed, 11 Feb 2026 22:22:41 +0530 Subject: [PATCH 7/7] Update .golangci.yml Co-authored-by: Oleksandr Redko --- .golangci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 71bac87e79b..adbb8a0c4d6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -287,11 +287,11 @@ linters: - IssueListByRepoOptions.Sort # TODO: Issues - IssueListByRepoOptions.Sort # TODO: Issues - IssueListByRepoOptions.State # TODO: Issues - - IssueListOptions.Direction # TODO: Issues - - IssueListOptions.Filter # TODO: Issues - - IssueListOptions.Since # TODO: Issues - - IssueListOptions.Sort # TODO: Issues - - IssueListOptions.State # TODO: Issues + - IssueListOptions.Direction # TODO: Issues + - IssueListOptions.Filter # TODO: Issues + - IssueListOptions.Since # TODO: Issues + - IssueListOptions.Sort # TODO: Issues + - IssueListOptions.State # TODO: Issues - IssueRequest.Assignees # TODO: Issues - IssueRequest.Labels # TODO: Issues - License.Conditions # TODO: Licenses