(c *C, ref string)
| 1359 | } |
| 1360 | |
| 1361 | func (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 | |
| 1405 | func (s *RepositorySuite) TestCloneSingleBranchHEADMain(c *C) { |
| 1406 | r, _ := Init(memory.NewStorage(), nil) |
no test coverage detected