| 63 | } |
| 64 | |
| 65 | func (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. |
| 87 | func rawHost(host string) string { |