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

Method TestCloneSparse

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

Source from the content-addressed store, hash-verified

297}
298
299func (s *RepositorySuite) TestCloneSparse(c *C) {
300 fs := memfs.New()
301 r, err := Clone(memory.NewStorage(), fs, &CloneOptions{
302 URL: s.GetBasicLocalRepositoryURL(),
303 NoCheckout: true,
304 })
305 c.Assert(err, IsNil)
306
307 w, err := r.Worktree()
308 c.Assert(err, IsNil)
309
310 sparseCheckoutDirectories := []string{"go", "json", "php"}
311 c.Assert(w.Checkout(&CheckoutOptions{
312 Branch: "refs/heads/master",
313 SparseCheckoutDirectories: sparseCheckoutDirectories,
314 }), IsNil)
315
316 fis, err := fs.ReadDir(".")
317 c.Assert(err, IsNil)
318 for _, fi := range fis {
319 c.Assert(fi.IsDir(), Equals, true)
320 var oneOfSparseCheckoutDirs bool
321
322 for _, sparseCheckoutDirectory := range sparseCheckoutDirectories {
323 if strings.HasPrefix(fi.Name(), sparseCheckoutDirectory) {
324 oneOfSparseCheckoutDirs = true
325 }
326 }
327 c.Assert(oneOfSparseCheckoutDirs, Equals, true)
328 }
329}
330
331func (s *RepositorySuite) TestCreateRemoteAndRemote(c *C) {
332 r, _ := Init(memory.NewStorage(), nil)

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