fix(iteration): show the real total in list header
Description
glab iteration list passed len(iterations) as both the count and the total
in its header, so the total was always the size of the current page. This is
the same bug !3991 (merged) fixed for label list, and was pointed out in its review.
This keeps the *gitlab.Response returned by ListProjectIterations and
ListGroupIterations, and builds the header with utils.NewListTitle, as
!3991 (merged) does for label list:
- The total comes from
resp.TotalItems. - When the response carries no total, the header omits "of N" instead of repeating the page count.
- An empty list prints
No iterations available on .... - The group case sets
RepoNameto the group, likemr list.
The header format changes accordingly, for example
Showing iteration 1 of 1 on OWNER/REPO. becomes
Showing 1 of 25 iterations on OWNER/REPO. (Page 1), and the group header
reads on GROUP instead of for group GROUP.
The iteration list body and the JSON output are unchanged.
Related Issues
Resolves #8591 (closed)
Follow-up to !3991 (merged) (#8573 (closed)).
How has this been tested?
-
internal/commands/iteration/list/iteration_list_test.go:- Updated the expected headers of the existing cases, including the empty
list, which now prints
No iterations available on OWNER/REPO. - Added
TestIterationListHeaderTotalwith a project case and a group case that mockTotalItems: 25and expectof 25, and a case where the response has no total. All three fail onmainwith1 of 1.
- Updated the expected headers of the existing cases, including the empty
list, which now prints
-
go test ./internal/commands/iteration/...andgo vet ./internal/commands/iteration/list/pass. -
golangci-lint run ./internal/commands/iteration/...(v2.14.0, as pinned in.tool-versions) reports 0 issues, andgolangci-lint fmt --diffreports no changes. -
go run ./scripts/comment-overlapreports 0 findings on the changed files. -
Ran a build of this branch against a self-managed GitLab 19.3.3-ee instance. It has no iterations, so only the empty-list header could be checked live:
Command mainThis branch glab iteration listShowing iteration 0 of 0 on OWNER/REPO.No iterations available on OWNER/REPO.glab iteration list -g GROUPShowing iteration 0 of 0 for group GROUP.No iterations available on GROUP.The
-F jsonoutput is byte-identical tomain.