RepoParent finds out the parent repository of a fork
(client *Client, repo ghrepo.Interface)
| 435 | |
| 436 | // RepoParent finds out the parent repository of a fork |
| 437 | func RepoParent(client *Client, repo ghrepo.Interface) (ghrepo.Interface, error) { |
| 438 | var query struct { |
| 439 | Repository struct { |
| 440 | Parent *struct { |
| 441 | Name string |
| 442 | Owner struct { |
| 443 | Login string |
| 444 | } |
| 445 | } |
| 446 | } `graphql:"repository(owner: $owner, name: $name)"` |
| 447 | } |
| 448 | |
| 449 | variables := map[string]interface{}{ |
| 450 | "owner": githubv4.String(repo.RepoOwner()), |
| 451 | "name": githubv4.String(repo.RepoName()), |
| 452 | } |
| 453 | |
| 454 | err := client.Query(repo.RepoHost(), "RepositoryFindParent", &query, variables) |
| 455 | if err != nil { |
| 456 | return nil, err |
| 457 | } |
| 458 | if query.Repository.Parent == nil { |
| 459 | return nil, nil |
| 460 | } |
| 461 | |
| 462 | parent := ghrepo.NewWithHost(query.Repository.Parent.Owner.Login, query.Repository.Parent.Name, repo.RepoHost()) |
| 463 | return parent, nil |
| 464 | } |
| 465 | |
| 466 | // RepoNetworkResult describes the relationship between related repositories |
| 467 | type RepoNetworkResult struct { |
no test coverage detected