fix(issue): show the real total in the list header
Description
glab issue list and glab incident list discarded the *gitlab.Response
from ListProjectIssues and ListGroupIssues, so the header only reported the
number of rows on the current page. With the default page size there was no way
to tell that more issues existed.
This keeps the response and passes resp.TotalItems to the list title, the same
approach as !3991 (merged) (label list) and !4015 (merged) (iteration list):
- The header reads, for example,
Showing 30 of 120 open issues in OWNER/REPO that match your search. (Page 1). - When the response carries no total (GitLab omits
X-Totalfor very large result sets), the header stays as it is today. --epickeeps the page count. Epic issues are filtered client-side, so the API total would not match the rows shown.
Only the header line changes. The table, --output json, and
--output-format ids|urls are unchanged.
This is the first of the per-command MRs announced in
#1165 (comment 3988459828).
schedule list and mr list follow separately. Step 1 of the implementation
plan in #1165 ((Page N of M) and the next-page hint) is not part of this MR,
because it changes the header of every list command.
!3256 rewrites the same project branch of listRun (the ListProjectIssues
call), so whichever of the two lands second will need a small rebase.
Related Issues
Related to #1165
How has this been tested?
-
internal/commands/issuable/list/issuable_list_test.go: addedTestIssueList_headerTotalwith five cases:- project, group (
--page 21), and incident responses with a total expectof 42/of 5. These three fail onmain. - a response without a total keeps
Showing 2 open issues .... --epicwith a response that carriesTotalItems: 42keepsShowing 2 open issues in GROUP&42 ....
- project, group (
-
go test ./internal/commands/issuable/... ./internal/commands/issue/... ./internal/commands/incident/... ./internal/utils/...andgo vet ./internal/commands/issuable/list/pass. -
golangci-lint run ./internal/commands/issuable/...(v2.14.0) reports 0 issues, andgolangci-lint fmt --diffreports no changes. -
go run ./scripts/comment-overlapreports 0 findings. -
Ran a build of this branch against a self-managed GitLab 19.3.3-ee instance (40 open issues in the project, 48 in the group):
Command mainThis branch glab issue list -P 5Showing 5 open issues in OWNER/REPO that match your search. (Page 1)Showing 5 of 40 open issues in OWNER/REPO that match your search. (Page 1)glab issue list -P 5 -p 2Showing 5 open issues in OWNER/REPO that match your search. (Page 2)Showing 5 of 40 open issues in OWNER/REPO that match your search. (Page 2)glab issue list -P 5 -cShowing 5 closed issues in OWNER/REPO that match your search. (Page 1)Showing 5 of 78 closed issues in OWNER/REPO that match your search. (Page 1)glab issue list -g GROUP -P 5Showing 5 open issues in GROUP that match your search. (Page 1)Showing 5 of 48 open issues in GROUP that match your search. (Page 1)The table body,
-O json(project and group), and-F urlsoutput are byte-identical tomain.