MCPcopy Index your code
hub / github.com/cli/cli / IssueRepoInfo

Function IssueRepoInfo

api/queries_repo.go:320–356  ·  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

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