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