extractAppNameFromGitRemote parses a Git remote and return the app name extracted out of it. The Git remote URL may look like: - SSH on a custom port: ssh://git@host:port/appName.git - GitHub: git@github.com:owner/appName.git
(url string)
| 277 | // - SSH on a custom port: ssh://git@host:port/appName.git |
| 278 | // - GitHub: git@github.com:owner/appName.git |
| 279 | func extractAppNameFromGitRemote(url string) string { |
| 280 | splittedURL := strings.Split(strings.TrimSuffix(url, ".git"), ":") |
| 281 | appName := splittedURL[len(splittedURL)-1] |
| 282 | // appName may contain "port/appName" or "owner/appName". We keep the part |
| 283 | // after the slash. |
| 284 | i := strings.LastIndex(appName, "/") |
| 285 | if i != -1 { |
| 286 | appName = appName[i+1:] |
| 287 | } |
| 288 | |
| 289 | return appName |
| 290 | } |
no outgoing calls