fix(repo): make --limit cap total results#135
Open
ychampion wants to merge 3 commits into
Open
Conversation
andrew
requested changes
Jul 8, 2026
andrew
left a comment
Contributor
There was a problem hiding this comment.
Thanks for picking this up. As written this doesn't fix #133 and regresses repo search:
- No backend reads
ListRepoOpts.LimitorSearchRepoOpts.Limit(seegithub/github.go:105,402,gitlab/gitlab.go:95,388,gitea/gitea.go:102,365,bitbucket/bitbucket.go:210).FilterReposinforge.godoesn't apply it either. Sorepo list --limit Nstill returns everything. Searchon every backend fetches a single page sized byPerPage. RemovingPerPage: flagLimitmeans--limit 5now 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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
repo list --limitoutput after the repo service returns results.repo search --limitas bothSearchRepoOpts.LimitandPerPage, then cap output after the search call.Why
Fixes #133.
--limitshould 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=1go test ./internal/cli -count=1go test ./... -count=1git diff --check