Only fetch DefaultBranchRef when adding upstream remote during gh repo clone
This commit is contained in:
parent
f4152454f2
commit
f536901bc1
5 changed files with 56 additions and 6 deletions
|
|
@ -144,7 +144,7 @@ func cloneRun(opts *CloneOptions) error {
|
|||
}
|
||||
upstreamURL := ghrepo.FormatRemoteURL(canonicalRepo.Parent, protocol)
|
||||
|
||||
err = git.AddUpstreamRemote(upstreamURL, cloneDir)
|
||||
err = git.AddUpstreamRemote(upstreamURL, cloneDir, []string{canonicalRepo.Parent.DefaultBranchRef.Name})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,6 +218,9 @@ func Test_RepoClone_hasParent(t *testing.T) {
|
|||
"name": "ORIG",
|
||||
"owner": {
|
||||
"login": "hubot"
|
||||
},
|
||||
"defaultBranchRef": {
|
||||
"name": "master"
|
||||
}
|
||||
}
|
||||
} } }
|
||||
|
|
@ -237,7 +240,7 @@ func Test_RepoClone_hasParent(t *testing.T) {
|
|||
}
|
||||
|
||||
assert.Equal(t, 2, cs.Count)
|
||||
assert.Equal(t, "git -C REPO remote add -f upstream https://github.com/hubot/ORIG.git", strings.Join(cs.Calls[1].Args, " "))
|
||||
assert.Equal(t, "git -C REPO remote add -t master -f upstream https://github.com/hubot/ORIG.git", strings.Join(cs.Calls[1].Args, " "))
|
||||
}
|
||||
|
||||
func Test_RepoClone_withoutUsername(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ func forkRun(opts *ForkOptions) error {
|
|||
}
|
||||
|
||||
upstreamURL := ghrepo.FormatRemoteURL(repoToFork, protocol)
|
||||
err = git.AddUpstreamRemote(upstreamURL, cloneDir)
|
||||
err = git.AddUpstreamRemote(upstreamURL, cloneDir, []string{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue