Skip to content

Commit

Permalink
Add origin remote if it's not already set on the repo
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGreen committed Jun 28, 2022
1 parent f217cd4 commit c99de0b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,14 @@ func (b *Bootstrap) updateGitMirror() (string, error) {
b.shell.Commentf("Updating existing repository mirror to find commit %s", b.Commit)

// Update the origin of the repository so we can gracefully handle repository renames
if err := b.shell.Run("git", "--git-dir", mirrorDir, "remote", "set-url", "origin", b.Repository); err != nil {
return "", err
if err := b.shell.Run("git", "remote", "get-url", "origin"); err != nil {
if err := b.shell.Run("git", "--git-dir", mirrorDir, "remote", "set-url", "origin", b.Repository); err != nil {
return "", err
}
} else {
if err := b.shell.Run("git", "--git-dir", mirrorDir, "remote", "add", "origin", b.Repository); err != nil {
return "", err
}
}

if b.PullRequest != "false" && strings.Contains(b.PipelineProvider, "github") {
Expand Down

0 comments on commit c99de0b

Please sign in to comment.