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

Function GetAppNameFromGitRemote

detect/app.go:205–220  ·  view source on GitHub ↗

GetAppNameFromGitRemote searches into the current directory and its parent for a remote named remoteName or scalingo- . It returns the application name and an error.

(ctx context.Context, directory string, remoteName string)

Source from the content-addressed store, hash-verified

203//
204// It returns the application name and an error.
205func GetAppNameFromGitRemote(ctx context.Context, directory string, remoteName string) (string, error) {
206 remotes, err := utils.ScalingoGitRemotes(ctx, directory)
207 if err != nil {
208 return "", errors.Wrapf(ctx, err, "list git remotes from %s", directory)
209 }
210
211 altRemoteName := "scalingo-" + remoteName
212 for _, remote := range remotes {
213 if remote.Config().Name == remoteName ||
214 remote.Config().Name == altRemoteName {
215 return extractAppNameFromGitRemote(remote.Config().URLs[0]), nil
216 }
217 }
218
219 return "", errors.Newf(ctx, "[detect] Scalingo Git remote hasn't been found")
220}
221
222// RemoteNameFromFlags returns the remote name specified in command flags
223func RemoteNameFromFlags(c *cli.Command) string {

Callers 2

CurrentAppCompletionFunction · 0.92
extractAppNameFunction · 0.85

Calls 2

ScalingoGitRemotesFunction · 0.92

Tested by

no test coverage detected