MCPcopy Create free account
hub / github.com/go-git/go-git / TestCheckoutSparse

Method TestCheckoutSparse

worktree_test.go:478–507  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

476}
477
478func (s *WorktreeSuite) TestCheckoutSparse(c *C) {
479 fs := memfs.New()
480 r, err := Clone(memory.NewStorage(), fs, &CloneOptions{
481 URL: s.GetBasicLocalRepositoryURL(),
482 })
483 c.Assert(err, IsNil)
484
485 w, err := r.Worktree()
486 c.Assert(err, IsNil)
487
488 sparseCheckoutDirectories := []string{"go", "json", "php"}
489 c.Assert(w.Checkout(&CheckoutOptions{
490 SparseCheckoutDirectories: sparseCheckoutDirectories,
491 }), IsNil)
492
493 fis, err := fs.ReadDir("/")
494 c.Assert(err, IsNil)
495
496 for _, fi := range fis {
497 c.Assert(fi.IsDir(), Equals, true)
498 var oneOfSparseCheckoutDirs bool
499
500 for _, sparseCheckoutDirectory := range sparseCheckoutDirectories {
501 if strings.HasPrefix(fi.Name(), sparseCheckoutDirectory) {
502 oneOfSparseCheckoutDirs = true
503 }
504 }
505 c.Assert(oneOfSparseCheckoutDirs, Equals, true)
506 }
507}
508
509func (s *WorktreeSuite) TestFilenameNormalization(c *C) {
510 if runtime.GOOS == "windows" {

Callers

nothing calls this directly

Calls 8

NewStorageFunction · 0.92
CloneFunction · 0.85
WorktreeMethod · 0.80
CheckoutMethod · 0.80
IsDirMethod · 0.65
NameMethod · 0.65
ReadDirMethod · 0.45

Tested by

no test coverage detected