From e87467d21fade4e6b3105f82892c80944c8f3154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Mon, 24 Feb 2020 17:17:14 +0100 Subject: [PATCH] Allow `repo view OWNER/REPO` format for owners starting with "http" --- command/repo.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/command/repo.go b/command/repo.go index 472b2e83f..2c0bdabfb 100644 --- a/command/repo.go +++ b/command/repo.go @@ -20,17 +20,16 @@ var repoCmd = &cobra.Command{ Long: `Work with GitHub repositories. A repository can be supplied as an argument in any of the following formats: -- by owner/repo, e.g. "cli/cli" -- by URL, e.g. "https://github.com/cli/cli"`, +- "OWNER/REPO" +- by URL, e.g. "https://github.com/OWNER/REPO"`, } var repoViewCmd = &cobra.Command{ - Use: "view [{ | }]", + Use: "view []", Short: "View a repository in the browser", - Long: `View a repository specified by the argument in the browser. + Long: `View a GitHub repository in the browser. -Without an argument, the repository that belongs to the current -branch is opened.`, +With no argument, the repository for the current directory is opened.`, RunE: repoView, } @@ -45,10 +44,11 @@ func repoView(cmd *cobra.Command, args []string) error { } openURL = fmt.Sprintf("https://github.com/%s", ghrepo.FullName(*baseRepo)) } else { - if strings.HasPrefix(args[0], "http") { - openURL = args[0] + repoArg := args[0] + if strings.HasPrefix(repoArg, "http:/") || strings.HasPrefix(repoArg, "https:/") { + openURL = repoArg } else { - openURL = fmt.Sprintf("https://github.com/%s", args[0]) + openURL = fmt.Sprintf("https://github.com/%s", repoArg) } }