MCPcopy Index your code
hub / github.com/github/github-mcp-server / queryRepoAccessInfo

Method queryRepoAccessInfo

pkg/lockdown/lockdown.go:244–270  ·  view source on GitHub ↗

queryRepoAccessInfo fetches repository visibility and the viewer login in a single GraphQL round-trip.

(ctx context.Context, owner, repo string)

Source from the content-addressed store, hash-verified

242
243// queryRepoAccessInfo fetches repository visibility and the viewer login in a single GraphQL round-trip.
244func (c *RepoAccessCache) queryRepoAccessInfo(ctx context.Context, owner, repo string) (bool, string, error) {
245 if c.client == nil {
246 return false, "", fmt.Errorf("nil GraphQL client")
247 }
248
249 var query struct {
250 Viewer struct {
251 Login githubv4.String
252 }
253 Repository struct {
254 IsPrivate githubv4.Boolean
255 } `graphql:"repository(owner: $owner, name: $name)"`
256 }
257
258 variables := map[string]any{
259 "owner": githubv4.String(owner),
260 "name": githubv4.String(repo),
261 }
262
263 if err := c.client.Query(ctx, &query, variables); err != nil {
264 return false, "", fmt.Errorf("failed to query repository metadata: %w", err)
265 }
266
267 c.logDebug(ctx, fmt.Sprintf("queried repo access info for %s/%s: isPrivate=%t", owner, repo, bool(query.Repository.IsPrivate)))
268
269 return bool(query.Repository.IsPrivate), string(query.Viewer.Login), nil
270}
271
272// checkPushAccess checks if the user has push access to the repository via the REST permission endpoint.
273func (c *RepoAccessCache) checkPushAccess(ctx context.Context, username, owner, repo string) (bool, error) {

Callers 1

getRepoAccessInfoMethod · 0.95

Calls 2

logDebugMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected