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

Function RepoParent

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

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