MCPcopy
hub / github.com/mislav/hub / GitURL

Method GitURL

github/project.go:65–84  ·  view source on GitHub ↗
(name, owner string, isSSH bool)

Source from the content-addressed store, hash-verified

63}
64
65func (p *Project) GitURL(name, owner string, isSSH bool) (url string) {
66 if name == "" {
67 name = p.Name
68 }
69 if owner == "" {
70 owner = p.Owner
71 }
72
73 host := rawHost(p.Host)
74
75 if preferredProtocol() == "https" {
76 url = fmt.Sprintf("https://%s/%s/%s.git", host, owner, name)
77 } else if isSSH || preferredProtocol() == "ssh" {
78 url = fmt.Sprintf("git@%s:%s/%s.git", host, owner, name)
79 } else {
80 url = fmt.Sprintf("git://%s/%s/%s.git", host, owner, name)
81 }
82
83 return url
84}
85
86// Remove the scheme from host when the host url is absolute.
87func rawHost(host string) string {

Callers 10

transformCherryPickArgsFunction · 0.95
transformInitArgsFunction · 0.95
getCloneUrlFunction · 0.95
transformFetchArgsFunction · 0.95
transformCheckoutArgsFunction · 0.95
transformRemoteArgsFunction · 0.95
forkFunction · 0.95
createFunction · 0.95
TestProject_GitURLFunction · 0.95

Calls 2

rawHostFunction · 0.85
preferredProtocolFunction · 0.85

Tested by 2

TestProject_GitURLFunction · 0.76