(ctx context.Context, repository *git.Repository, remoteName string, url string, force bool)
| 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) |
| 42 | if err != nil { |
| 43 | return errors.Wrapf(ctx, err, "check if git remote %s exists", remoteName) |
| 44 | } |
| 45 | if has && force { |
| 46 | err := deleteThenCreateRemoteInRepository(ctx, repository, remoteName, url) |
| 47 | if err != nil { |
| 48 | return errors.Wrapf(ctx, err, "replace git remote %s", remoteName) |
| 49 | } |
| 50 | return nil |
| 51 | } |
| 52 | err = createRemoteInRepository(ctx, repository, remoteName, url) |
| 53 | if err != nil { |
| 54 | return errors.Wrapf(ctx, err, "create git remote %s", remoteName) |
| 55 | } |
| 56 | return nil |
| 57 | } |
| 58 | |
| 59 | func createRemoteInRepository(ctx context.Context, repository *git.Repository, remoteName string, url string) error { |
| 60 | _, err := repository.CreateRemote(&gitconfig.RemoteConfig{ |
no test coverage detected