Add 'internal' case for repositoryQuery#62266
Conversation
eseliger
left a comment
There was a problem hiding this comment.
LGTM, we talked through this on a call. In a next step, we want to announce that public will change behavior in a future version and that internal should be added as well, when public was used before.
|
|
||
| for _, org := range orgs { | ||
| sb.WriteString("org:") | ||
| sb.WriteString(org.Login) |
There was a problem hiding this comment.
I hope those can't contain spaces or colons themselves 😬
| // a search query. This leads to much fewer requests to the GitHub API. | ||
| func (s *GitHubSource) listInternal(ctx context.Context, results chan *githubResult) { | ||
| orgs, err := fetchAll(func(page int) (items []*github.Org, hasNext bool, cost int, err error) { | ||
| return s.v3Client.GetAuthenticatedUserOrgs(ctx, page) |
There was a problem hiding this comment.
I'm assuming that works with GitHub App installations as well, where only a subset of orgs may be granted access to?
There was a problem hiding this comment.
GitHub App installations are tied to a single org/user. So this wouldn't have worked. I added a special case in case we're dealing with a github app, although it would be more efficient for the admin to add a repositoryQuery with org:org-name is:internal than any options the GitHub App installations API gives us.
Actually, perhaps that's what we should do 🤔 return an error asking them to do that
|
@pjlast Can we update changelog too? |
Co-authored-by: Erik Seliger <erikseliger@me.com>
…/61924-ghe-internal-repos-support
Closes #61924
Docs update: sourcegraph/docs#286
Adds 'internal' as a special case option for the repositoryQuery field on GitHub code host connections. This query will fetch all orgs the user of the PAT belongs to and construct a search query consisting of
org:org1 org:org2 ... is:internal.A search query is used instead of the standard
org/reposendpoint, because for a large amount of orgs it is much faster to fetch all of the repositories with the search API than to hit the/reposendpoint for each individual org.Test plan
Test added for
"repositoryQuery": ["internal"]