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

Function IssueRepoInfo

api/queries_repo.go:321–358  ·  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 databaseId
327 name
328 owner { login }
329 hasIssuesEnabled
330 viewerPermission
331 }
332 }`
333 variables := map[string]any{
334 "owner": repo.RepoOwner(),
335 "name": repo.RepoName(),
336 }
337
338 var result struct {
339 Repository *Repository
340 }
341 if err := client.GraphQL(repo.RepoHost(), query, variables, &result); err != nil {
342 return nil, err
343 }
344 // The GraphQL API should have returned an error in case of a missing repository, but this isn't
345 // guaranteed to happen when an authentication token with insufficient permissions is being used.
346 if result.Repository == nil {
347 return nil, GraphQLError{
348 GraphQLError: &ghAPI.GraphQLError{
349 Errors: []ghAPI.GraphQLErrorItem{{
350 Type: "NOT_FOUND",
351 Message: fmt.Sprintf("Could not resolve to a Repository with the name '%s/%s'.", repo.RepoOwner(), repo.RepoName()),
352 }},
353 },
354 }
355 }
356
357 return InitRepoHostname(result.Repository, repo.RepoHost()), nil
358}
359
360func GitHubRepo(client *Client, repo ghrepo.Interface) (*Repository, error) {
361 query := `

Callers 6

issueTransferFunction · 0.92
createRunFunction · 0.92

Calls 5

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