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

Method TestCloneSingleBranch

repository_test.go:1448–1483  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

1446}
1447
1448func (s *RepositorySuite) TestCloneSingleBranch(c *C) {
1449 r, _ := Init(memory.NewStorage(), nil)
1450
1451 head, err := r.Head()
1452 c.Assert(err, Equals, plumbing.ErrReferenceNotFound)
1453 c.Assert(head, IsNil)
1454
1455 err = r.clone(context.Background(), &CloneOptions{
1456 URL: s.GetBasicLocalRepositoryURL(),
1457 SingleBranch: true,
1458 })
1459
1460 c.Assert(err, IsNil)
1461
1462 remotes, err := r.Remotes()
1463 c.Assert(err, IsNil)
1464 c.Assert(remotes, HasLen, 1)
1465
1466 cfg, err := r.Config()
1467 c.Assert(err, IsNil)
1468 c.Assert(cfg.Branches, HasLen, 1)
1469 c.Assert(cfg.Branches["master"].Name, Equals, "master")
1470 c.Assert(cfg.Branches["master"].Remote, Equals, "origin")
1471 c.Assert(cfg.Branches["master"].Merge, Equals, plumbing.ReferenceName("refs/heads/master"))
1472
1473 head, err = r.Reference(plumbing.HEAD, false)
1474 c.Assert(err, IsNil)
1475 c.Assert(head, NotNil)
1476 c.Assert(head.Type(), Equals, plumbing.SymbolicReference)
1477 c.Assert(head.Target().String(), Equals, "refs/heads/master")
1478
1479 branch, err := r.Reference(head.Target(), false)
1480 c.Assert(err, IsNil)
1481 c.Assert(branch, NotNil)
1482 c.Assert(branch.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
1483}
1484
1485func (s *RepositorySuite) TestCloneSingleTag(c *C) {
1486 r, _ := Init(memory.NewStorage(), nil)

Callers

nothing calls this directly

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