From 2eb97fb44707bc122c53bf2ad8eaf24ad8d679f4 Mon Sep 17 00:00:00 2001 From: Dustin Frisch Date: Wed, 9 May 2018 12:50:49 +0200 Subject: [PATCH 1/2] Use remote name in fetch while clone Fixes #827 Signed-off-by: Dustin Frisch --- repository.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/repository.go b/repository.go index 717381bdb..247966611 100644 --- a/repository.go +++ b/repository.go @@ -520,10 +520,11 @@ 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, + Depth: o.Depth, + Auth: o.Auth, + Progress: o.Progress, + Tags: o.Tags, + RemoteName: o.RemoteName, }, o.ReferenceName) if err != nil { return err From 529f8438980a29999ca44f3a3e74eb317d0cf3c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ximo=20Cuadros?= Date: Mon, 15 Oct 2018 11:28:12 +0200 Subject: [PATCH 2/2] use remote name in fetch while clone, test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Máximo Cuadros --- repository.go | 2 +- repository_test.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/repository.go b/repository.go index 247966611..2d20f49fc 100644 --- a/repository.go +++ b/repository.go @@ -519,7 +519,7 @@ func (r *Repository) clone(ctx context.Context, o *CloneOptions) error { } ref, err := r.fetchAndUpdateReferences(ctx, &FetchOptions{ - RefSpecs: r.cloneRefSpec(o, c), + RefSpecs: r.cloneRefSpec(o, c), Depth: o.Depth, Auth: o.Auth, Progress: o.Progress, diff --git a/repository_test.go b/repository_test.go index b78fbb70b..9303bef02 100644 --- a/repository_test.go +++ b/repository_test.go @@ -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()