From 7e1ed5f9a34bbb624aec4d6c1a0c260a51f3119f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Spie=C3=9F?= Date: Sun, 5 Apr 2020 20:54:29 +0200 Subject: [PATCH] Fetch upstream remote after adding it --- command/repo.go | 2 +- command/repo_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/command/repo.go b/command/repo.go index afc6ddec7..e7ac12b83 100644 --- a/command/repo.go +++ b/command/repo.go @@ -143,7 +143,7 @@ func addUpstreamRemote(parentRepo ghrepo.Interface, cloneURL string) error { upstreamURL := fmt.Sprintf("https://github.com/%s.git", ghrepo.FullName(parentRepo)) cloneDir := path.Base(strings.TrimSuffix(cloneURL, ".git")) - cloneCmd := git.GitCommand("-C", cloneDir, "remote", "add", "upstream", upstreamURL) + cloneCmd := git.GitCommand("-C", cloneDir, "remote", "add", "-f", "upstream", upstreamURL) cloneCmd.Stdout = os.Stdout cloneCmd.Stderr = os.Stderr return run.PrepareCmd(cloneCmd).Run() diff --git a/command/repo_test.go b/command/repo_test.go index f0d271cf8..baeed3722 100644 --- a/command/repo_test.go +++ b/command/repo_test.go @@ -185,7 +185,7 @@ func TestRepoFork_outside_yes(t *testing.T) { eq(t, output.Stderr(), "") eq(t, strings.Join(cs.Calls[0].Args, " "), "git clone https://github.com/someone/repo.git") - eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add upstream https://github.com/OWNER/REPO.git") + eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add -f upstream https://github.com/OWNER/REPO.git") test.ExpectLines(t, output.String(), "Created fork someone/REPO", @@ -218,7 +218,7 @@ func TestRepoFork_outside_survey_yes(t *testing.T) { eq(t, output.Stderr(), "") eq(t, strings.Join(cs.Calls[0].Args, " "), "git clone https://github.com/someone/repo.git") - eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add upstream https://github.com/OWNER/REPO.git") + eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add -f upstream https://github.com/OWNER/REPO.git") test.ExpectLines(t, output.String(), "Created fork someone/REPO", @@ -414,7 +414,7 @@ func TestRepoClone_hasParent(t *testing.T) { } eq(t, cs.Count, 2) - eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C REPO remote add upstream https://github.com/hubot/ORIG.git") + eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C REPO remote add -f upstream https://github.com/hubot/ORIG.git") } func TestRepoCreate(t *testing.T) {