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

Method TestCheckoutSymlink

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 13

PlainInitFunction · 0.85
defaultSignatureFunction · 0.85
WorktreeMethod · 0.80
JoinMethod · 0.80
CheckoutMethod · 0.80
SkipMethod · 0.65
CommitMethod · 0.65
SetIndexMethod · 0.65
SymlinkMethod · 0.45
AddMethod · 0.45
StatusMethod · 0.45
IsCleanMethod · 0.45

Tested by

no test coverage detected