(raw string)
| 5033 | } |
| 5034 | |
| 5035 | func extractRemoteHostPath(raw string) (string, string, bool) { |
| 5036 | trimmed := strings.TrimSpace(raw) |
| 5037 | if trimmed == "" { |
| 5038 | return "", "", false |
| 5039 | } |
| 5040 | |
| 5041 | trimmed = strings.TrimSuffix(trimmed, ".git") |
| 5042 | trimmed = strings.TrimSuffix(trimmed, "/") |
| 5043 | |
| 5044 | if strings.Contains(trimmed, "://") { |
| 5045 | u, err := url.Parse(trimmed) |
| 5046 | if err == nil { |
| 5047 | host := strings.ToLower(u.Host) |
| 5048 | if strings.HasPrefix(host, "git@") { |
| 5049 | host = strings.TrimPrefix(host, "git@") |
| 5050 | } |
| 5051 | if colon := strings.IndexRune(host, ':'); colon >= 0 { |
| 5052 | host = host[:colon] |
| 5053 | } |
| 5054 | path := strings.Trim(u.Path, "/") |
| 5055 | return host, path, true |
| 5056 | } |
| 5057 | } |
| 5058 | |
| 5059 | if strings.HasPrefix(trimmed, "git@") { |
| 5060 | parts := strings.SplitN(trimmed, ":", 2) |
| 5061 | if len(parts) == 2 { |
| 5062 | host := strings.ToLower(strings.TrimPrefix(parts[0], "git@")) |
| 5063 | path := strings.Trim(parts[1], "/") |
| 5064 | return host, path, true |
| 5065 | } |
| 5066 | } |
| 5067 | |
| 5068 | return "", trimmed, false |
| 5069 | } |
| 5070 | |
| 5071 | func ensureGitRepository() error { |
| 5072 | cmd := exec.Command("git", "rev-parse", "--is-inside-work-tree") |
no outgoing calls
no test coverage detected