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

Function _stubPR

pkg/cmd/pr/checkout/checkout_test.go:126–163  ·  view source on GitHub ↗
(repo, prHead string, number int, title string, state string, isDraft bool)

Source from the content-addressed store, hash-verified

124}
125
126func _stubPR(repo, prHead string, number int, title string, state string, isDraft bool) (ghrepo.Interface, *api.PullRequest) {
127 defaultBranch := ""
128 if idx := strings.IndexRune(repo, ':'); idx >= 0 {
129 defaultBranch = repo[idx+1:]
130 repo = repo[:idx]
131 }
132 baseRepo, err := ghrepo.FromFullName(repo)
133 if err != nil {
134 panic(err)
135 }
136 if defaultBranch != "" {
137 baseRepo = api.InitRepoHostname(&api.Repository{
138 Name: baseRepo.RepoName(),
139 Owner: api.RepositoryOwner{Login: baseRepo.RepoOwner()},
140 DefaultBranchRef: api.BranchRef{Name: defaultBranch},
141 }, baseRepo.RepoHost())
142 }
143
144 idx := strings.IndexRune(prHead, ':')
145 headRefName := prHead[idx+1:]
146 headRepo, err := ghrepo.FromFullName(prHead[:idx])
147 if err != nil {
148 panic(err)
149 }
150
151 return baseRepo, &api.PullRequest{
152 Number: number,
153 HeadRefName: headRefName,
154 HeadRepositoryOwner: api.Owner{Login: headRepo.RepoOwner()},
155 HeadRepository: &api.PRRepository{Name: headRepo.RepoName()},
156 IsCrossRepository: !ghrepo.IsSame(baseRepo, headRepo),
157 MaintainerCanModify: false,
158
159 Title: title,
160 State: state,
161 IsDraft: isDraft,
162 }
163}
164
165type stubPRResolver struct {
166 pr *api.PullRequest

Callers 2

stubPRFunction · 0.85
TestPromptingPRResolverFunction · 0.85

Calls 6

FromFullNameFunction · 0.92
InitRepoHostnameFunction · 0.92
IsSameFunction · 0.92
RepoNameMethod · 0.65
RepoOwnerMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected