MCPcopy Create free account
hub / github.com/Scalingo/cli / extractAppNameFromGitRemote

Function extractAppNameFromGitRemote

detect/app.go:279–290  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

277// - SSH on a custom port: ssh://git@host:port/appName.git
278// - GitHub: git@github.com:owner/appName.git
279func 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}

Callers 2

GetAppNameFromGitRemoteFunction · 0.85

Calls

no outgoing calls

Tested by 1