MCPcopy Create free account
hub / github.com/cli/cli / IssueRepoInfo

Function IssueRepoInfo

api/queries_repo.go:321–357  ·  view source on GitHub ↗

IssueRepoInfo fetches only the repository fields needed for issue operations such as issue creation and transfer, avoiding fields like defaultBranchRef that require additional token permissions.

(client *Client, repo ghrepo.Interface)

Source from the content-addressed store, hash-verified

319// issue creation and transfer, avoiding fields like defaultBranchRef that require additional
320// token permissions.
321func IssueRepoInfo(client *Client, repo ghrepo.Interface) (*Repository, error) {
322 query := `
323 query IssueRepositoryInfo($owner: String!, $name: String!) {
324 repository(owner: $owner, name: $name) {
325 id
326 name
327 owner { login }
328 hasIssuesEnabled
329 viewerPermission
330 }
331 }`
332 variables := map[string]interface{}{
333 "owner": repo.RepoOwner(),
334 "name": repo.RepoName(),
335 }
336
337 var result struct {
338 Repository *Repository
339 }
340 if err := client.GraphQL(repo.RepoHost(), query, variables, &result); err != nil {
341 return nil, err
342 }
343 // The GraphQL API should have returned an error in case of a missing repository, but this isn't
344 // guaranteed to happen when an authentication token with insufficient permissions is being used.
345 if result.Repository == nil {
346 return nil, GraphQLError{
347 GraphQLError: &ghAPI.GraphQLError{
348 Errors: []ghAPI.GraphQLErrorItem{{
349 Type: "NOT_FOUND",
350 Message: fmt.Sprintf("Could not resolve to a Repository with the name '%s/%s'.", repo.RepoOwner(), repo.RepoName()),
351 }},
352 },
353 }
354 }
355
356 return InitRepoHostname(result.Repository, repo.RepoHost()), nil
357}
358
359func GitHubRepo(client *Client, repo ghrepo.Interface) (*Repository, error) {
360 query := `

Callers 5

issueTransferFunction · 0.92
createRunFunction · 0.92

Calls 5

InitRepoHostnameFunction · 0.85
GraphQLMethod · 0.80
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RepoHostMethod · 0.65

Tested by 3