fix(vcs): discover private repositories of personal accounts - #42
Merged
Conversation
git-sync listed a GitHub personal account through GET /users/{owner}/repos,
which returns public repositories only whatever token is presented, so private
repositories were silently missing from every run with no error to point at.
When the token belongs to the configured owner, list through
GET /user/repos?visibility=all&affiliation=owner instead, which reports them.
Mirroring another account still sees its public repositories only, since no
credential can see further.
A GitLab source in a user namespace failed outright at the discover stage,
because only GET /groups/{owner}/projects was tried and it 404s for a personal
namespace. A 404 on the first page now falls back to
GET /users/{owner}/projects.
A mirror whose discovery succeeds but reports nothing now warns and names the
likely cause, since an empty run was otherwise indistinguishable from a mirror
that is up to date.
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.
What
git-syncsilently mirrored only the public half of a GitHub personal account, and failed outright on a GitLab user namespace.Why
Listing fell back to
GET /users/{owner}/reposwhen the owner was not an organisation. GitHub documents that endpoint as returning public repositories only, and it does not widen for an authenticated caller. The run reported0 selectedwith no error, which is indistinguishable from a mirror that is up to date.GitLab only ever tried
GET /groups/{owner}/projects, which 404s for a personal namespace, so the whole mirror died at thediscoverstage.Changes
GET /user, cached per run), list throughGET /user/repos?visibility=all&affiliation=owner. Mirroring another account still uses the public listing, since no credential can see further.GET /users/{owner}/projects. A non-404 error still fails, and a 404 partway through pagination is still a real failure rather than a reason to restart against a different endpoint.Audit of the other providers
No change needed. Bitbucket
/repositories/{workspace}returns private repositories to an authenticated caller, Azure DevOps lists project-scoped repositories which are private by default, and CodeCommitListRepositoriesis account scoped.Testing
Four new tests: the token owner uses the authenticated endpoint with
visibility=all, another account uses the public endpoint, GitLab falls back to the user namespace, and a GitLab 401 does not trigger the fallback.verify-syncerdfull tier passes.