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

Function createRemoteInRepository

git/setup.go:59–73  ·  view source on GitHub ↗
(ctx context.Context, repository *git.Repository, remoteName string, url string)

Source from the content-addressed store, hash-verified

57}
58
59func createRemoteInRepository(ctx context.Context, repository *git.Repository, remoteName string, url string) error {
60 _, err := repository.CreateRemote(&gitconfig.RemoteConfig{
61 Name: remoteName,
62 URLs: []string{url},
63 })
64 if err != nil {
65 errWrapped := errors.Wrapf(ctx, err, "create the Git remote")
66 if err == git.ErrRemoteExists {
67 message := "Fail to configure git repository, '" + remoteName + "' remote already exists (use --force option to override)"
68 errWrapped = errors.Wrap(ctx, errWrapped, message)
69 }
70 return errWrapped
71 }
72 return nil
73}
74
75func deleteThenCreateRemoteInRepository(ctx context.Context, repository *git.Repository, remoteName string, url string) error {
76 err := repository.DeleteRemote(remoteName)

Callers 2

putRemoteInRepositoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected