(ctx context.Context, repository *git.Repository, remoteName string, url string)
| 57 | } |
| 58 | |
| 59 | func 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 | |
| 75 | func deleteThenCreateRemoteInRepository(ctx context.Context, repository *git.Repository, remoteName string, url string) error { |
| 76 | err := repository.DeleteRemote(remoteName) |
no outgoing calls
no test coverage detected