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

Function RepoParent

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

439
440// RepoParent finds out the parent repository of a fork
441func 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
471type 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