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

Method TestCheckoutSymlink

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

Source from the content-addressed store, hash-verified

443}
444
445func (s *WorktreeSuite) TestCheckoutSymlink(c *C) {
446 if runtime.GOOS == "windows" {
447 c.Skip("git doesn't support symlinks by default in windows")
448 }
449
450 dir, clean := s.TemporalDir()
451 defer clean()
452
453 r, err := PlainInit(dir, false)
454 c.Assert(err, IsNil)
455
456 w, err := r.Worktree()
457 c.Assert(err, IsNil)
458
459 w.Filesystem.Symlink("not-exists", "bar")
460 w.Add("bar")
461 w.Commit("foo", &CommitOptions{Author: defaultSignature()})
462
463 r.Storer.SetIndex(&index.Index{Version: 2})
464 w.Filesystem = osfs.New(filepath.Join(dir, "worktree-empty"))
465
466 err = w.Checkout(&CheckoutOptions{})
467 c.Assert(err, IsNil)
468
469 status, err := w.Status()
470 c.Assert(err, IsNil)
471 c.Assert(status.IsClean(), Equals, true)
472
473 target, err := w.Filesystem.Readlink("bar")
474 c.Assert(target, Equals, "not-exists")
475 c.Assert(err, IsNil)
476}
477
478func (s *WorktreeSuite) TestCheckoutSparse(c *C) {
479 fs := memfs.New()

Callers

nothing calls this directly

Calls 14

PlainInitFunction · 0.85
defaultSignatureFunction · 0.85
TemporalDirMethod · 0.80
WorktreeMethod · 0.80
SymlinkMethod · 0.80
JoinMethod · 0.80
CheckoutMethod · 0.80
ReadlinkMethod · 0.80
SkipMethod · 0.65
CommitMethod · 0.65
SetIndexMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected