MCPcopy
hub / github.com/cli/cli / stubPR

Function stubPR

pkg/cmd/pr/close/close_test.go:26–60  ·  view source on GitHub ↗

repo: either "baseOwner/baseRepo" or "baseOwner/baseRepo:defaultBranch" prHead: "headOwner/headRepo:headBranch"

(repo, prHead string)

Source from the content-addressed store, hash-verified

24// repo: either "baseOwner/baseRepo" or "baseOwner/baseRepo:defaultBranch"
25// prHead: "headOwner/headRepo:headBranch"
26func stubPR(repo, prHead string) (ghrepo.Interface, *api.PullRequest) {
27 defaultBranch := ""
28 if idx := strings.IndexRune(repo, ':'); idx >= 0 {
29 defaultBranch = repo[idx+1:]
30 repo = repo[:idx]
31 }
32 baseRepo, err := ghrepo.FromFullName(repo)
33 if err != nil {
34 panic(err)
35 }
36 if defaultBranch != "" {
37 baseRepo = api.InitRepoHostname(&api.Repository{
38 Name: baseRepo.RepoName(),
39 Owner: api.RepositoryOwner{Login: baseRepo.RepoOwner()},
40 DefaultBranchRef: api.BranchRef{Name: defaultBranch},
41 }, baseRepo.RepoHost())
42 }
43
44 idx := strings.IndexRune(prHead, ':')
45 headRefName := prHead[idx+1:]
46 headRepo, err := ghrepo.FromFullName(prHead[:idx])
47 if err != nil {
48 panic(err)
49 }
50
51 return baseRepo, &api.PullRequest{
52 ID: "THE-ID",
53 Number: 96,
54 State: "OPEN",
55 HeadRefName: headRefName,
56 HeadRepositoryOwner: api.Owner{Login: headRepo.RepoOwner()},
57 HeadRepository: &api.PRRepository{Name: headRepo.RepoName()},
58 IsCrossRepository: !ghrepo.IsSame(baseRepo, headRepo),
59 }
60}
61
62func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, error) {
63 ios, _, stdout, stderr := iostreams.Test()

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