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 RepoName to the group, like mr 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.

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 TestIterationListHeaderTotal with a project case and a group case that mock TotalItems: 25 and expect of 25, and a case where the response has no total. All three fail on main with 1 of 1.
  • go test ./internal/commands/iteration/... and go vet ./internal/commands/iteration/list/ pass.

  • golangci-lint run ./internal/commands/iteration/... (v2.14.0, as pinned in .tool-versions) reports 0 issues, and golangci-lint fmt --diff reports no changes.

  • go run ./scripts/comment-overlap reports 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 main This branch
    glab iteration list Showing iteration 0 of 0 on OWNER/REPO. No iterations available on OWNER/REPO.
    glab iteration list -g GROUP Showing iteration 0 of 0 for group GROUP. No iterations available on GROUP.

    The -F json output is byte-identical to main.

Merge request reports

Loading
Loading