Skip to content

Commit

Permalink
Merge pull request src-d#828 from fooker/patch-1
Browse files Browse the repository at this point in the history
Use remote name in fetch while clone
  • Loading branch information
mcuadros authored Oct 15, 2018
2 parents 0bfe038 + 529f843 commit 0381008
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
11 changes: 6 additions & 5 deletions repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,11 +654,12 @@ func (r *Repository) clone(ctx context.Context, o *CloneOptions) error {
}

ref, err := r.fetchAndUpdateReferences(ctx, &FetchOptions{
RefSpecs: r.cloneRefSpec(o, c),
Depth: o.Depth,
Auth: o.Auth,
Progress: o.Progress,
Tags: o.Tags,
RefSpecs: r.cloneRefSpec(o, c),
Depth: o.Depth,
Auth: o.Auth,
Progress: o.Progress,
Tags: o.Tags,
RemoteName: o.RemoteName,
}, o.ReferenceName)
if err != nil {
return err
Expand Down
13 changes: 13 additions & 0 deletions repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,19 @@ func (s *RepositorySuite) TestPlainClone(c *C) {
c.Assert(cfg.Branches["master"].Name, Equals, "master")
}

func (s *RepositorySuite) TestPlainCloneWithRemoteName(c *C) {
r, err := PlainClone(c.MkDir(), false, &CloneOptions{
URL: s.GetBasicLocalRepositoryURL(),
RemoteName: "test",
})

c.Assert(err, IsNil)

remote, err := r.Remote("test")
c.Assert(err, IsNil)
c.Assert(remote, NotNil)
}

func (s *RepositorySuite) TestPlainCloneContext(c *C) {
ctx, cancel := context.WithCancel(context.Background())
cancel()
Expand Down

0 comments on commit 0381008

Please sign in to comment.