Skip to content

Commit e87467d

Browse files
committed
Allow repo view OWNER/REPO format for owners starting with "http"
1 parent 398a5de commit e87467d

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

command/repo.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,16 @@ var repoCmd = &cobra.Command{
2020
Long: `Work with GitHub repositories.
2121
2222
A repository can be supplied as an argument in any of the following formats:
23-
- by owner/repo, e.g. "cli/cli"
24-
- by URL, e.g. "https://github.com/cli/cli"`,
23+
- "OWNER/REPO"
24+
- by URL, e.g. "https://github.com/OWNER/REPO"`,
2525
}
2626

2727
var repoViewCmd = &cobra.Command{
28-
Use: "view [{<owner/repo> | <url>}]",
28+
Use: "view [<repo>]",
2929
Short: "View a repository in the browser",
30-
Long: `View a repository specified by the argument in the browser.
30+
Long: `View a GitHub repository in the browser.
3131
32-
Without an argument, the repository that belongs to the current
33-
branch is opened.`,
32+
With no argument, the repository for the current directory is opened.`,
3433
RunE: repoView,
3534
}
3635

@@ -45,10 +44,11 @@ func repoView(cmd *cobra.Command, args []string) error {
4544
}
4645
openURL = fmt.Sprintf("https://github.com/%s", ghrepo.FullName(*baseRepo))
4746
} else {
48-
if strings.HasPrefix(args[0], "http") {
49-
openURL = args[0]
47+
repoArg := args[0]
48+
if strings.HasPrefix(repoArg, "http:/") || strings.HasPrefix(repoArg, "https:/") {
49+
openURL = repoArg
5050
} else {
51-
openURL = fmt.Sprintf("https://github.com/%s", args[0])
51+
openURL = fmt.Sprintf("https://github.com/%s", repoArg)
5252
}
5353
}
5454

0 commit comments

Comments
 (0)