Skip to content

Commit e878cdf

Browse files
authored
Merge pull request cli#752 from lumaxis/feature/fetch-upstream-after-adding
Fetch upstream remote after adding it Fixes cli#731
2 parents e10ccef + 7e1ed5f commit e878cdf

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

command/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func addUpstreamRemote(parentRepo ghrepo.Interface, cloneDir string) error {
169169
// TODO: support SSH remote URLs
170170
upstreamURL := fmt.Sprintf("https://github.com/%s.git", ghrepo.FullName(parentRepo))
171171

172-
cloneCmd := git.GitCommand("-C", cloneDir, "remote", "add", "upstream", upstreamURL)
172+
cloneCmd := git.GitCommand("-C", cloneDir, "remote", "add", "-f", "upstream", upstreamURL)
173173
cloneCmd.Stdout = os.Stdout
174174
cloneCmd.Stderr = os.Stderr
175175
return run.PrepareCmd(cloneCmd).Run()

command/repo_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func TestRepoFork_outside_yes(t *testing.T) {
186186
eq(t, output.Stderr(), "")
187187

188188
eq(t, strings.Join(cs.Calls[0].Args, " "), "git clone https://github.com/someone/repo.git")
189-
eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add upstream https://github.com/OWNER/REPO.git")
189+
eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add -f upstream https://github.com/OWNER/REPO.git")
190190

191191
test.ExpectLines(t, output.String(),
192192
"Created fork someone/REPO",
@@ -219,7 +219,7 @@ func TestRepoFork_outside_survey_yes(t *testing.T) {
219219
eq(t, output.Stderr(), "")
220220

221221
eq(t, strings.Join(cs.Calls[0].Args, " "), "git clone https://github.com/someone/repo.git")
222-
eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add upstream https://github.com/OWNER/REPO.git")
222+
eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add -f upstream https://github.com/OWNER/REPO.git")
223223

224224
test.ExpectLines(t, output.String(),
225225
"Created fork someone/REPO",
@@ -484,7 +484,7 @@ func TestRepoClone_hasParent(t *testing.T) {
484484
}
485485

486486
eq(t, cs.Count, 2)
487-
eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C REPO remote add upstream https://github.com/hubot/ORIG.git")
487+
eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C REPO remote add -f upstream https://github.com/hubot/ORIG.git")
488488
}
489489

490490
func TestRepoCreate(t *testing.T) {

0 commit comments

Comments
 (0)