repo: either "baseOwner/baseRepo" or "baseOwner/baseRepo:defaultBranch" prHead: "headOwner/headRepo:headBranch"
(repo, prHead string)
| 24 | // repo: either "baseOwner/baseRepo" or "baseOwner/baseRepo:defaultBranch" |
| 25 | // prHead: "headOwner/headRepo:headBranch" |
| 26 | func 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 | |
| 62 | func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, error) { |
| 63 | ios, _, stdout, stderr := iostreams.Test() |
no test coverage detected