Skip to content

Commit 6a0749b

Browse files
committed
init-repo: set remote if already cloned
1 parent 1e11f10 commit 6a0749b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmd/init-repo/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,16 @@ func run(c *exec.Cmd) {
215215
}
216216

217217
func cloneSourceRepo(cfg config.Config, runGodepRestore bool) {
218+
repoLocation := fmt.Sprintf("https://%s/%s/%s", cfg.GithubHost, cfg.SourceOrg, cfg.SourceRepo)
219+
218220
if _, err := os.Stat(filepath.Join(BaseRepoPath, cfg.SourceRepo)); err == nil {
219-
glog.Infof("Source repository %q already cloned, skipping", cfg.SourceRepo)
221+
glog.Infof("Source repository %q already cloned, only setting remote", cfg.SourceRepo)
222+
remoteCmd := exec.Command("git", "remote", "set-url", "origin", repoLocation)
223+
remoteCmd.Dir = filepath.Join(BaseRepoPath, cfg.SourceRepo)
224+
run(remoteCmd)
220225
return
221226
}
222227

223-
repoLocation := fmt.Sprintf("https://%s/%s/%s", cfg.GithubHost, cfg.SourceOrg, cfg.SourceRepo)
224228
glog.Infof("Cloning source repository %s ...", repoLocation)
225229
cloneCmd := exec.Command("git", "clone", repoLocation)
226230
run(cloneCmd)

0 commit comments

Comments
 (0)