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

Method TestCheckoutBranchUntracked

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

Source from the content-addressed store, hash-verified

808}
809
810func (s *WorktreeSuite) TestCheckoutBranchUntracked(c *C) {
811 w := &Worktree{
812 r: s.Repository,
813 Filesystem: memfs.New(),
814 }
815
816 uf, err := w.Filesystem.Create("untracked_file")
817 c.Assert(err, IsNil)
818 _, err = uf.Write([]byte("don't delete me"))
819 c.Assert(err, IsNil)
820
821 err = w.Checkout(&CheckoutOptions{
822 Branch: "refs/heads/branch",
823 })
824 c.Assert(err, IsNil)
825
826 head, err := w.r.Head()
827 c.Assert(err, IsNil)
828 c.Assert(head.Name().String(), Equals, "refs/heads/branch")
829
830 status, err := w.Status()
831 c.Assert(err, IsNil)
832 // The untracked file should still be there, so it's not clean
833 c.Assert(status.IsClean(), Equals, false)
834 c.Assert(status.IsUntracked("untracked_file"), Equals, true)
835 err = w.Filesystem.Remove("untracked_file")
836 c.Assert(err, IsNil)
837 status, err = w.Status()
838 c.Assert(err, IsNil)
839 // After deleting the untracked file it should now be clean
840 c.Assert(status.IsClean(), Equals, true)
841}
842
843func (s *WorktreeSuite) TestCheckoutCreateWithHash(c *C) {
844 w := &Worktree{

Callers

nothing calls this directly

Calls 10

CheckoutMethod · 0.95
StatusMethod · 0.95
HeadMethod · 0.80
IsUntrackedMethod · 0.80
StringMethod · 0.65
NameMethod · 0.65
CreateMethod · 0.45
WriteMethod · 0.45
IsCleanMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected