move generateRepoURL to ghrepo

This commit is contained in:
vilmibm 2020-07-23 11:16:47 -05:00
parent 895af993a5
commit dc02366128
5 changed files with 14 additions and 22 deletions

View file

@ -97,7 +97,7 @@ func viewRun(opts *ViewOptions) error {
return err
}
openURL := generateRepoURL(toView, "")
openURL := ghrepo.GenerateRepoURL(toView, "")
if opts.Web {
if opts.IO.IsStdoutTTY() {
fmt.Fprintf(opts.IO.ErrOut, "Opening %s in your browser.\n", displayURL(openURL))
@ -192,14 +192,6 @@ func isURL(arg string) bool {
return strings.HasPrefix(arg, "http:/") || strings.HasPrefix(arg, "https:/")
}
func generateRepoURL(repo ghrepo.Interface, p string, args ...interface{}) string {
baseURL := fmt.Sprintf("https://%s/%s/%s", repo.RepoHost(), repo.RepoOwner(), repo.RepoName())
if p != "" {
return baseURL + "/" + fmt.Sprintf(p, args...)
}
return baseURL
}
func displayURL(urlStr string) string {
u, err := url.Parse(urlStr)
if err != nil {