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

Function _stubPR

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

Source from the content-addressed store, hash-verified

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