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-Total for very large result sets), the header stays as it is today.
  • --epic keeps 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 to #1165

How has this been tested?

  • internal/commands/issuable/list/issuable_list_test.go: added TestIssueList_headerTotal with five cases:

    • project, group (--page 21), and incident responses with a total expect of 42 / of 5. These three fail on main.
    • a response without a total keeps Showing 2 open issues ....
    • --epic with a response that carries TotalItems: 42 keeps Showing 2 open issues in GROUP&42 ....
  • go test ./internal/commands/issuable/... ./internal/commands/issue/... ./internal/commands/incident/... ./internal/utils/... and go vet ./internal/commands/issuable/list/ pass.

  • golangci-lint run ./internal/commands/issuable/... (v2.14.0) reports 0 issues, and golangci-lint fmt --diff reports no changes.

  • go run ./scripts/comment-overlap reports 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 main This branch
    glab issue list -P 5 Showing 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 2 Showing 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 -c Showing 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 5 Showing 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 urls output are byte-identical to main.

Edited by unstable-code

Merge request reports

Loading
Loading