Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Use remote name in fetch while clone #828

Merged
merged 2 commits into from
Oct 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,11 +519,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 @@ -566,6 +566,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