(ctx context.Context, appName string, params SetupParams)
| 17 | } |
| 18 | |
| 19 | func Setup(ctx context.Context, appName string, params SetupParams) error { |
| 20 | repo, err := git.PlainOpen(".") |
| 21 | if err != nil { |
| 22 | return errors.Wrapf(ctx, err, "fail to initialize the Git repository") |
| 23 | } |
| 24 | |
| 25 | url, err := getGitEndpoint(ctx, appName) |
| 26 | if err != nil { |
| 27 | return errors.Wrapf(ctx, err, "fail to get the Git endpoint of this app") |
| 28 | } |
| 29 | debug.Println("Adding Git remote", url) |
| 30 | |
| 31 | err = putRemoteInRepository(ctx, repo, params.RemoteName, url, params.ForcePutRemote) |
| 32 | if err != nil { |
| 33 | return errors.Wrapf(ctx, err, "configure git remote %s", params.RemoteName) |
| 34 | } |
| 35 | |
| 36 | io.Status("Successfully added the Git remote", params.RemoteName, "on", appName) |
| 37 | return nil |
| 38 | } |
| 39 | |
| 40 | func putRemoteInRepository(ctx context.Context, repository *git.Repository, remoteName string, url string, force bool) error { |
| 41 | has, err := repositoryHasRemote(ctx, repository, remoteName) |
no test coverage detected