From ce0e1d7e351268c7f9b848354f1b07ca2f84ca59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Mon, 7 Oct 2019 16:34:52 +0200 Subject: [PATCH] Remove unused functionality from 'project' --- github/project.go | 66 ++--------------------------------------------- 1 file changed, 2 insertions(+), 64 deletions(-) diff --git a/github/project.go b/github/project.go index e2773950f..142532f2d 100644 --- a/github/project.go +++ b/github/project.go @@ -3,11 +3,8 @@ package github import ( "fmt" "net/url" - "os" - "path/filepath" "strings" - "github.com/github/gh-cli/git" "github.com/github/gh-cli/utils" ) @@ -37,23 +34,6 @@ func (p *Project) WebURL(name, owner, path string) string { } ownerWithName := fmt.Sprintf("%s/%s", owner, name) - if strings.Contains(ownerWithName, ".wiki") { - ownerWithName = strings.TrimSuffix(ownerWithName, ".wiki") - if path != "wiki" { - if strings.HasPrefix(path, "commits") { - path = "_history" - } else if path != "" { - path = fmt.Sprintf("_%s", path) - } - - if path != "" { - path = utils.ConcatPaths("wiki", path) - } else { - path = "wiki" - } - } - } - url := fmt.Sprintf("%s://%s", p.Protocol, utils.ConcatPaths(p.Host, ownerWithName)) if path != "" { url = utils.ConcatPaths(url, path) @@ -62,45 +42,8 @@ func (p *Project) WebURL(name, owner, path string) string { return url } -func (p *Project) GitURL(name, owner string, isSSH bool) (url string) { - if name == "" { - name = p.Name - } - if owner == "" { - owner = p.Owner - } - - host := rawHost(p.Host) - - if preferredProtocol() == "https" { - url = fmt.Sprintf("https://%s/%s/%s.git", host, owner, name) - } else if isSSH || preferredProtocol() == "ssh" { - url = fmt.Sprintf("git@%s:%s/%s.git", host, owner, name) - } else { - url = fmt.Sprintf("git://%s/%s/%s.git", host, owner, name) - } - - return url -} - -// Remove the scheme from host when the host url is absolute. -func rawHost(host string) string { - u, err := url.Parse(host) - utils.Check(err) - - if u.IsAbs() { - return u.Host - } else { - return u.Path - } -} - -func preferredProtocol() string { - userProtocol := os.Getenv("HUB_PROTOCOL") - if userProtocol == "" { - userProtocol, _ = git.Config("hub.protocol") - } - return userProtocol +func (p *Project) GitURL(name, owner string, isSSH bool) string { + return p.WebURL(name, owner, "") + ".git" } func NewProjectFromURL(url *url.URL) (p *Project, err error) { @@ -174,8 +117,3 @@ func newProject(owner, name, host, protocol string) *Project { Protocol: protocol, } } - -func SanitizeProjectName(name string) string { - name = filepath.Base(name) - return strings.Replace(name, " ", "-", -1) -}