Add --limit flag and default sort to pipeline list#59
Merged
gildas merged 3 commits intogildas:devfrom Mar 15, 2026
Merged
Conversation
Pipeline list hangs on repositories with many pipelines because GetAll fetches every page before returning. This adds a --limit flag to cap total results and breaks the pagination loop early. Also defaults to sort=-created_on so newest pipelines are returned first. Fixes gildas#57 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update --sort flag description to clarify it applies a local sort on fetched results, not server-side sorting - Cap pagelen to min(pageLength, limit) so --limit 5 only fetches 5 items from the API instead of a full page of 50 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
888fcc1 to
82e5844
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the Bitbucket CLI’s pipeline listing behavior to avoid unbounded pagination work by introducing an optional total-result cap and by requesting pipelines from the API in newest-first order.
Changes:
- Add generic
--limitsupport inprofile.GetAllto stop pagination once enough results are collected and to reducepagelenwhen possible. - Add
--limitflag tobb pipeline list. - Default the pipeline list API request to
sort=-created_on(newest-first at the API level).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| cmd/profile/profile_client.go | Adds generic --limit handling to GetAll, including early pagination exit and pagelen adjustment. |
| cmd/pipeline/list.go | Adds --limit flag and requests pipelines with server-side sort=-created_on. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Log effectivePageLength and limit instead of raw pageLength - Adjust pagelen on subsequent pages to only fetch remaining items when limit is set, avoiding over-fetching on the last request - Only apply local sort when --sort is explicitly provided, preserving the server-side created_on descending order by default
Contributor
Author
|
@gildas lmk if you need anything changed |
Owner
|
Sorry for the delay, I could not look at it lately, work was very intense. Still is, but at least I don't have to work today. |
gildas
approved these changes
Mar 15, 2026
Owner
|
thanks again for your contribution! Very much appreciated |
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
--limitflag topipeline listto cap total results, breaking the pagination loop early inGetAllsort=-created_onso newest pipelines are returned firstpagelentomin(pageLength, limit)to avoid over-fetching from the API--limitsupport inGetAllis generic — other list commands can opt in by registering the same flagMotivation
bb pipeline listhangs on repositories with many pipelines becauseGetAllfetches every page before returning any output. Unlikepullrequest list(which defaults tostate=OPEN), pipeline list has no default filter and fetches all historical pipelines.Usage
Test plan
bb pipeline list --limit 10returns exactly 10 pipelinesbb pipeline list --limit 10completes quickly (1-2 API calls)bb pipeline listwithout--limitstill works, now sorted newest firstbb pipeline list --limit 5 --query 'state.name="SUCCESSFUL"'respects both flagsFixes #57
Resubmitted against
devwith signed commits per maintainer request (replaces #58).