perf(adopt): scope to local branches, walk chains on demand (v0.2.25)#24
Merged
Conversation
ez adopt now uses targeted GraphQL lookups instead of paginating every
PR in the repo. On onyx (~10k PRs) this drops the time to adopt 12
local PRs from ~120s to ~1.4s.
Default mode (no args):
- Fetch PRs only for local branches via get_pr_statuses_for.
- No ancestor expansion. Local PRs whose base isn't local-with-PR or
trunk are warned about with a hint to use ez adopt --pr <N> to walk
the remote chain explicitly.
--branches <names>:
- Fetch named branches, then expand_ancestor_chains walks bases
iteratively, fetching one batch per stack level via GraphQL.
- Bounded by stack depth, not repo PR count.
--pr <N>:
- Adds github::get_pr_by_number — single GraphQL call for one PR by
number, returning head branch + info.
- Same chain expansion as --branches.
Internal:
- Extract expand_ancestor_chains_with that takes the fetcher as a
closure so tests can stub the network.
- Extract orphan_local_prs helper for sorted, deterministic warnings.
- Remove obsolete filter_prs_for_requested_branches and chain_to_trunk
that the global-scan flow needed.
5 new unit tests:
- expand_ancestor_chains fetches missing parents until trunk.
- terminates when base has no upstream PR (no infinite loop on tried).
- no fetches when all bases are already trunk.
- orphan_local_prs flags branches with non-local non-trunk bases.
- orphan output is sorted (deterministic warning order).
Bumps version to 0.2.25.
Cleanup of comments that just restated function names or obvious code. Kept the two WHYs that matter: tried set prevents infinite loop on broken chains, default mode deliberately skips expansion to avoid re-introducing per-PR network cost.
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
ez adoptno longer scans every PR in the repo. On onyx (~10k PRs) adopting 12 local PRs went from ~120s to ~1.4s.The old
get_all_pr_statusespaginated through every PR ever opened just to find the few that matter. Now each mode does targeted fetches:Default —
ez adoptOne GraphQL call: PR statuses for local branches only. No ancestor expansion. If a local PR's base isn't local-with-PR or trunk, we warn and skip with a hint to use
--pr <N>for explicit chain walking.ez adopt feat/a feat/bFetch the named branches' PRs, then
expand_ancestor_chainswalks bases iteratively, one GraphQL batch per stack level. Bounded by stack depth.ez adopt --pr <N>New
github::get_pr_by_number— one GraphQL call to look up the PR by number, returning head branch + PrInfo. Then expand chain like--branches.Smoke test (onyx, ~10k PRs, 12 local branches with PRs)
Note the correctly-chained 3-deep stack (
metrics-1a→1b→1c): default mode picks up multi-level stacks for free, because each level's PR base is another local branch in the fetch set.Tests
5 new unit tests, 219 total pass:
expand_ancestor_chainsfetches missing parents until trunk (verified with a stubbed fetcher).triedset).orphan_local_prsflags branches with non-local non-trunk bases.Internal refactor
expand_ancestor_chains_with(prs, trunk, fetch)takes the fetcher as a closure so tests can stub the network without setting up a fakegh.orphan_local_prs(prs, trunk) -> Vec<&String>extracts the "what wouldbuild_adopt_graphdrop?" logic fromrun.filter_prs_for_requested_branchesandchain_to_trunkthat the old global-scan flow needed.get_all_pr_statusesis no longer called anywhere; left in place with its existing tests for now.Test plan
cargo test— 219 passcargo fmt --all -- --checkcleancargo clippy -- -D warningsclean on lib codeez adoptsmoke test on onyx — 1.4s adopts 12 local PRs including a 3-deep stack