(client *Client, repo ghrepo.Interface, fields []string)
| 283 | } |
| 284 | |
| 285 | func FetchRepository(client *Client, repo ghrepo.Interface, fields []string) (*Repository, error) { |
| 286 | query := fmt.Sprintf(`query RepositoryInfo($owner: String!, $name: String!) { |
| 287 | repository(owner: $owner, name: $name) {%s} |
| 288 | }`, RepositoryGraphQL(fields)) |
| 289 | |
| 290 | variables := map[string]interface{}{ |
| 291 | "owner": repo.RepoOwner(), |
| 292 | "name": repo.RepoName(), |
| 293 | } |
| 294 | |
| 295 | var result struct { |
| 296 | Repository *Repository |
| 297 | } |
| 298 | if err := client.GraphQL(repo.RepoHost(), query, variables, &result); err != nil { |
| 299 | return nil, err |
| 300 | } |
| 301 | // The GraphQL API should have returned an error in case of a missing repository, but this isn't |
| 302 | // guaranteed to happen when an authentication token with insufficient permissions is being used. |
| 303 | if result.Repository == nil { |
| 304 | return nil, GraphQLError{ |
| 305 | GraphQLError: &ghAPI.GraphQLError{ |
| 306 | Errors: []ghAPI.GraphQLErrorItem{{ |
| 307 | Type: "NOT_FOUND", |
| 308 | Message: fmt.Sprintf("Could not resolve to a Repository with the name '%s/%s'.", repo.RepoOwner(), repo.RepoName()), |
| 309 | }}, |
| 310 | }, |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | return InitRepoHostname(result.Repository, repo.RepoHost()), nil |
| 315 | } |
| 316 | |
| 317 | // IssueRepoInfo fetches only the repository fields needed for issue operations such as |
| 318 | // issue creation and transfer, avoiding fields like defaultBranchRef that require additional |
no test coverage detected