MCPcopy
hub / github.com/go-git/go-git / testCloneSingleBranchAndNonHEADReference

Method testCloneSingleBranchAndNonHEADReference

repository_test.go:1361–1403  ·  view source on GitHub ↗
(c *C, ref string)

Source from the content-addressed store, hash-verified

1359}
1360
1361func (s *RepositorySuite) testCloneSingleBranchAndNonHEADReference(c *C, ref string) {
1362 r, _ := Init(memory.NewStorage(), nil)
1363
1364 head, err := r.Head()
1365 c.Assert(err, Equals, plumbing.ErrReferenceNotFound)
1366 c.Assert(head, IsNil)
1367
1368 err = r.clone(context.Background(), &CloneOptions{
1369 URL: s.GetBasicLocalRepositoryURL(),
1370 ReferenceName: plumbing.ReferenceName(ref),
1371 SingleBranch: true,
1372 })
1373
1374 c.Assert(err, IsNil)
1375
1376 remotes, err := r.Remotes()
1377 c.Assert(err, IsNil)
1378 c.Assert(remotes, HasLen, 1)
1379
1380 cfg, err := r.Config()
1381 c.Assert(err, IsNil)
1382 c.Assert(cfg.Branches, HasLen, 1)
1383 c.Assert(cfg.Branches["branch"].Name, Equals, "branch")
1384 c.Assert(cfg.Branches["branch"].Remote, Equals, "origin")
1385 c.Assert(cfg.Branches["branch"].Merge, Equals, plumbing.ReferenceName("refs/heads/branch"))
1386
1387 head, err = r.Reference(plumbing.HEAD, false)
1388 c.Assert(err, IsNil)
1389 c.Assert(head, NotNil)
1390 c.Assert(head.Type(), Equals, plumbing.SymbolicReference)
1391 c.Assert(head.Target().String(), Equals, "refs/heads/branch")
1392
1393 branch, err := r.Reference(head.Target(), false)
1394 c.Assert(err, IsNil)
1395 c.Assert(branch, NotNil)
1396 c.Assert(branch.Hash().String(), Equals, "e8d3ffab552895c19b9fcf7aa264d277cde33881")
1397
1398 branch, err = r.Reference("refs/remotes/origin/branch", false)
1399 c.Assert(err, IsNil)
1400 c.Assert(branch, NotNil)
1401 c.Assert(branch.Type(), Equals, plumbing.HashReference)
1402 c.Assert(branch.Hash().String(), Equals, "e8d3ffab552895c19b9fcf7aa264d277cde33881")
1403}
1404
1405func (s *RepositorySuite) TestCloneSingleBranchHEADMain(c *C) {
1406 r, _ := Init(memory.NewStorage(), nil)

Calls 13

NewStorageFunction · 0.92
ReferenceNameTypeAlias · 0.92
InitFunction · 0.85
HeadMethod · 0.80
cloneMethod · 0.80
RemotesMethod · 0.80
TargetMethod · 0.80
ConfigMethod · 0.65
ReferenceMethod · 0.65
TypeMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected