Repository navigation
fix: use the repository default branch in the GitHub connector - #6800
Merged
timothycarambat merged 2 commits intoOct 21, 2026
Merged
Conversation
…s back GitHubRepoLoader picked main or master whenever no branch was given or the given branch did not exist on the remote, without checking the repository. A repository with a different default branch got another branch or one that does not exist; mrdoob/three.js, for example, resolved to its release-only master instead of dev. Read default_branch from the repository metadata on the resolved API root and prefer it, falling back to main/master when the lookup fails, the same way GiteaRepoLoader already does.
2 tasks done
The connector UI preselects the first branch returned, which was always main/master, so the init fallback alone never changed what users imported. getRepoBranches now lists default_branch first, init only looks it up when the requested branch is missing, and the token is validated before the branch list is fetched.
Member
|
Thanks @Enesuygurs, the
Live against |
This was referenced Oct 22, 2026
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.
Pull Request Type
Relevant Issues
resolves #6799
Description
GitHubRepoLoaderauto-assigns a branch when none is given or the given one does not exist on the remote. It pickedmainormasterwithout looking at the repository, so a repository with a different default branch got either another branch or one that does not exist. Formrdoob/three.js(default branchdev, plus a release-onlymaster), the loader resolved tomaster.This adds
fetchDefaultBranch(), which readsdefault_branchfromGET /repos/{owner}/{repo}on the resolved API root, so it works for github.com, GitHub Enterprise Server and GHE.com alike.#validBranch()now prefers that branch the same wayGiteaRepoLoaderalready does, and falls back tomain/masteras before when the metadata cannot be read. An explicitly provided branch that exists is kept, and the extra request is skipped.Tests:
mockGithubApinow serves the repository metadata endpoint, and a newGitHubRepoLoader branch resolutionblock mirrors the Gitea tests:mainand thenmasterare used when the metadata request failsThree of the six tests fail without the change.
Visuals (if applicable)
N/A
Additional Information
I also checked this against the live GitHub API with
mrdoob/three.js:init()without a branch resolves tomasterbefore the change and todevafter it.Validation (Node 26.5.0, Windows):
GithubRepo.test.js: 40 of 40 tests pass.collectortest suites: 418 of 421 tests pass. The 3 failures are inWhisperProviders/ffmpegand fail the same way on an unmodified checkout, since ffmpeg is not installed on this machine.yarn lint:checkincollector, the only package this touches, passes. I did not run the rootyarn lintor a Docker build.Developer Validations
yarn lintfrom the root of the repo & committed changes