MCPcopy
hub / github.com/cli/cli / RepoParent

Function RepoParent

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

435
436// RepoParent finds out the parent repository of a fork
437func 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
467type RepoNetworkResult struct {

Callers 1

executeRemoteRepoSyncFunction · 0.92

Calls 6

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

Tested by

no test coverage detected