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

Function RepoParent

api/queries_repo.go:440–467  ·  view source on GitHub ↗

RepoParent finds out the parent repository of a fork

(client *Client, repo ghrepo.Interface)

Source from the content-addressed store, hash-verified

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

Callers 1

executeRemoteRepoSyncFunction · 0.92

Calls 6

NewWithHostFunction · 0.92
StringMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
QueryMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected