Avoid API requests in repo view when repo argument is given
This commit is contained in:
parent
7c76fb645a
commit
20fc0dfcb7
2 changed files with 17 additions and 10 deletions
|
|
@ -36,13 +36,13 @@ branch is opened.`,
|
|||
|
||||
func repoView(cmd *cobra.Command, args []string) error {
|
||||
ctx := contextForCommand(cmd)
|
||||
baseRepo, err := determineBaseRepo(cmd, ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var openURL string
|
||||
if len(args) == 0 {
|
||||
baseRepo, err := determineBaseRepo(cmd, ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
openURL = fmt.Sprintf("https://github.com/%s", ghrepo.FullName(*baseRepo))
|
||||
} else {
|
||||
if strings.HasPrefix(args[0], "http") {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"os/exec"
|
||||
"testing"
|
||||
|
||||
"github.com/cli/cli/context"
|
||||
"github.com/cli/cli/utils"
|
||||
)
|
||||
|
||||
|
|
@ -35,9 +36,12 @@ func TestRepoView(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRepoView_ownerRepo(t *testing.T) {
|
||||
initBlankContext("OWNER/REPO", "master")
|
||||
http := initFakeHTTP()
|
||||
http.StubRepoResponse("OWNER", "REPO")
|
||||
ctx := context.NewBlank()
|
||||
ctx.SetBranch("master")
|
||||
initContext = func() context.Context {
|
||||
return ctx
|
||||
}
|
||||
initFakeHTTP()
|
||||
|
||||
var seenCmd *exec.Cmd
|
||||
restoreCmd := utils.SetPrepareCmd(func(cmd *exec.Cmd) utils.Runnable {
|
||||
|
|
@ -62,9 +66,12 @@ func TestRepoView_ownerRepo(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRepoView_fullURL(t *testing.T) {
|
||||
initBlankContext("OWNER/REPO", "master")
|
||||
http := initFakeHTTP()
|
||||
http.StubRepoResponse("OWNER", "REPO")
|
||||
ctx := context.NewBlank()
|
||||
ctx.SetBranch("master")
|
||||
initContext = func() context.Context {
|
||||
return ctx
|
||||
}
|
||||
initFakeHTTP()
|
||||
|
||||
var seenCmd *exec.Cmd
|
||||
restoreCmd := utils.SetPrepareCmd(func(cmd *exec.Cmd) utils.Runnable {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue