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

Method TestCheckoutSparse

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

Source from the content-addressed store, hash-verified

531}
532
533func (s *WorktreeSuite) TestCheckoutSparse(c *C) {
534 fs := memfs.New()
535 r, err := Clone(memory.NewStorage(), fs, &CloneOptions{
536 URL: s.GetBasicLocalRepositoryURL(),
537 NoCheckout: true,
538 })
539 c.Assert(err, IsNil)
540
541 w, err := r.Worktree()
542 c.Assert(err, IsNil)
543
544 sparseCheckoutDirectories := []string{"go", "json", "php"}
545 c.Assert(w.Checkout(&CheckoutOptions{
546 SparseCheckoutDirectories: sparseCheckoutDirectories,
547 }), IsNil)
548
549 fis, err := fs.ReadDir("/")
550 c.Assert(err, IsNil)
551
552 for _, fi := range fis {
553 c.Assert(fi.IsDir(), Equals, true)
554 var oneOfSparseCheckoutDirs bool
555
556 for _, sparseCheckoutDirectory := range sparseCheckoutDirectories {
557 if strings.HasPrefix(fi.Name(), sparseCheckoutDirectory) {
558 oneOfSparseCheckoutDirs = true
559 }
560 }
561 c.Assert(oneOfSparseCheckoutDirs, Equals, true)
562 }
563}
564
565func (s *WorktreeSuite) TestFilenameNormalization(c *C) {
566 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