Skip to content

fix(repo): make --limit cap total results#135

Open
ychampion wants to merge 3 commits into
git-pkgs:mainfrom
ychampion:fix-repo-limit-total
Open

fix(repo): make --limit cap total results#135
ychampion wants to merge 3 commits into
git-pkgs:mainfrom
ychampion:fix-repo-limit-total

Conversation

@ychampion

@ychampion ychampion commented Jul 8, 2026

Copy link
Copy Markdown

Summary

  • Cap repo list --limit output after the repo service returns results.
  • Keep repo search --limit as both SearchRepoOpts.Limit and PerPage, then cap output after the search call.
  • Cover both paths with CLI tests that return more repos than the limit and assert the printed row count.

Why

Fixes #133. --limit should cap the total number of repositories printed. Search still uses the limit as the backend page size because the current search backends fetch one page.

Validation

  • go test ./internal/cli -run 'TestRepo(List|Search)LimitCapsTotalResults' -count=1
  • go test ./internal/cli -count=1
  • go test ./... -count=1
  • git diff --check

Copilot AI review requested due to automatic review settings July 8, 2026 11:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread internal/resolve/resolve.go Outdated
Comment thread internal/cli/repo_test.go

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up. As written this doesn't fix #133 and regresses repo search:

  • No backend reads ListRepoOpts.Limit or SearchRepoOpts.Limit (see github/github.go:105,402, gitlab/gitlab.go:95,388, gitea/gitea.go:102,365, bitbucket/bitbucket.go:210). FilterRepos in forge.go doesn't apply it either. So repo list --limit N still returns everything.
  • Search on every backend fetches a single page sized by PerPage. Removing PerPage: flagLimit means --limit 5 now returns 30 results instead of 5.

Please apply the two changes below so --limit actually caps output, and update the tests to prove it by returning more repos than the limit and checking the printed count. Stopping backend pagination early can be a follow-up.

Comment thread internal/cli/repo.go
Comment thread internal/cli/repo.go Outdated
Apply the review-requested output cap in the CLI after repo list/search calls so backends that do not honor Limit cannot over-print. Keep search PerPage tied to the user limit because search backends fetch a single page.

Constraint: Backends currently ignore ListRepoOpts.Limit and SearchRepoOpts.Limit.
Rejected: relying on backend pagination changes | larger follow-up than this review requested.
Confidence: high
Scope-risk: narrow
Directive: Keep CLI output caps until repo backends implement total Limit consistently.
Tested: go test ./internal/cli -run 'TestRepo(List|Search)LimitCapsTotalResults' -count=1
Tested: go test ./internal/cli -count=1
Tested: go test ./... -count=1
Tested: git diff --check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix repo limit flag to cap total results

3 participants