Skip to content

fix(git): list every branch via one git ls-remote - #380

Open
mihir-kandoi wants to merge 2 commits into
developfrom
fix/github-branch-pagination
Open

fix(git): list every branch via one git ls-remote#380
mihir-kandoi wants to merge 2 commits into
developfrom
fix/github-branch-pagination

Conversation

@mihir-kandoi

@mihir-kandoi mihir-kandoi commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

GitHubClient.list_branches fetched a single per_page=100 REST page. GitHub sorts branches alphabetically, so branch-heavy repos silently lost their version-* tail — frappe/erpnext keeps version-16-hotfix at position 588 of 589, so the add-app dialog's Branch dropdown could never show it while listing lookalikes like l10n_version-16-hotfix (position 69).

Rather than paging the REST API (N requests against a 60/hour unauthenticated budget, plus an arbitrary cap to defend), this lists heads with one git ls-remote: every branch, one round trip, no rate limit, using the same scoped-header token plumbing clones use. Git authentication failures map to GitAuthError so the endpoint keeps marking stale tokens invalid.

Smoke-tested against frappe/erpnext: 589 branches returned, version-16-hotfix present. Unit tests cover parsing, the token header (and that it stays out of argv), auth-failure mapping, other git failures, and timeouts. Independent of #377/#378.

The REST branch listing took a single per_page=100 page. GitHub sorts
branches alphabetically, so branch-heavy repos lost their version-* tail:
frappe/erpnext keeps version-16-hotfix at position 588 of 589, and the
add-app dialog could never list it while showing lookalikes such as
l10n_version-16-hotfix (position 69).

ls-remote returns all heads in one round trip, costs no API rate limit
(the public tab may be unauthenticated at 60 requests/hour), and reuses
the header-based token plumbing clones already use. Authentication
failures map to GitAuthError so the endpoint still marks stale tokens.
@mihir-kandoi
mihir-kandoi force-pushed the fix/github-branch-pagination branch from e6c8969 to 427eb8d Compare August 10, 2026 01:39
@mihir-kandoi mihir-kandoi changed the title fix(git): page through all branches when listing a repository fix(git): list every branch via one git ls-remote Aug 10, 2026
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.

1 participant