MCPcopy
hub / github.com/cli/cli / _stubPR

Function _stubPR

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

Source from the content-addressed store, hash-verified

111}
112
113func _stubPR(repo, prHead string, number int, title string, state string, isDraft bool) (ghrepo.Interface, *api.PullRequest) {
114 defaultBranch := ""
115 if idx := strings.IndexRune(repo, ':'); idx >= 0 {
116 defaultBranch = repo[idx+1:]
117 repo = repo[:idx]
118 }
119 baseRepo, err := ghrepo.FromFullName(repo)
120 if err != nil {
121 panic(err)
122 }
123 if defaultBranch != "" {
124 baseRepo = api.InitRepoHostname(&api.Repository{
125 Name: baseRepo.RepoName(),
126 Owner: api.RepositoryOwner{Login: baseRepo.RepoOwner()},
127 DefaultBranchRef: api.BranchRef{Name: defaultBranch},
128 }, baseRepo.RepoHost())
129 }
130
131 idx := strings.IndexRune(prHead, ':')
132 headRefName := prHead[idx+1:]
133 headRepo, err := ghrepo.FromFullName(prHead[:idx])
134 if err != nil {
135 panic(err)
136 }
137
138 return baseRepo, &api.PullRequest{
139 Number: number,
140 HeadRefName: headRefName,
141 HeadRepositoryOwner: api.Owner{Login: headRepo.RepoOwner()},
142 HeadRepository: &api.PRRepository{Name: headRepo.RepoName()},
143 IsCrossRepository: !ghrepo.IsSame(baseRepo, headRepo),
144 MaintainerCanModify: false,
145
146 Title: title,
147 State: state,
148 IsDraft: isDraft,
149 }
150}
151
152type stubPRResolver struct {
153 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