Skip to content

Commit

Permalink
fix: git remote add fix
Browse files Browse the repository at this point in the history
lets not fail if we try and add a git remote if one already exists

Signed-off-by: James Strachan <[email protected]>
  • Loading branch information
jstrachan authored and jenkins-x-bot committed Oct 24, 2019
1 parent 15e951f commit a1d1b7d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/gits/git_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a1d1b7d

Please sign in to comment.