From a1d1b7d2fff76b35f0996558e31414b8911bb497 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Thu, 24 Oct 2019 17:36:36 +0100 Subject: [PATCH] fix: git remote add fix lets not fail if we try and add a git remote if one already exists Signed-off-by: James Strachan --- pkg/gits/git_cli.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/gits/git_cli.go b/pkg/gits/git_cli.go index 9a5532a3b7..0879bab8d8 100644 --- a/pkg/gits/git_cli.go +++ b/pkg/gits/git_cli.go @@ -266,7 +266,14 @@ func (g *GitCLI) ResetToUpstream(dir string, branch string) error { // AddRemote adds a remote repository at the given URL and with the given name func (g *GitCLI) AddRemote(dir string, name string, url string) error { - return g.gitCmd(dir, "remote", "add", name, url) + err := g.gitCmd(dir, "remote", "add", name, url) + if err != nil { + err = g.gitCmd(dir, "remote", "set-url", name, url) + if err != nil { + return err + } + } + return nil } // UpdateRemote updates the URL of the remote repository