]>
Commit | Line | Data |
---|---|---|
1 | package getter | |
2 | ||
3 | // GitDetector implements Detector to detect Git SSH URLs such as | |
4 | // git@host.com:dir1/dir2 and converts them to proper URLs. | |
5 | type GitDetector struct{} | |
6 | ||
7 | func (d *GitDetector) Detect(src, _ string) (string, bool, error) { | |
8 | if len(src) == 0 { | |
9 | return "", false, nil | |
10 | } | |
11 | ||
12 | u, err := detectSSH(src) | |
13 | if err != nil { | |
14 | return "", true, err | |
15 | } | |
16 | if u == nil { | |
17 | return "", false, nil | |
18 | } | |
19 | ||
20 | // We require the username to be "git" to assume that this is a Git URL | |
21 | if u.User.Username() != "git" { | |
22 | return "", false, nil | |
23 | } | |
24 | ||
25 | return "git::" + u.String(), true, nil | |
26 | } |