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

Method TestAddGlob

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

Source from the content-addressed store, hash-verified

1870}
1871
1872func (s *WorktreeSuite) TestAddGlob(c *C) {
1873 fs := memfs.New()
1874 w := &Worktree{
1875 r: s.Repository,
1876 Filesystem: fs,
1877 }
1878
1879 err := w.Checkout(&CheckoutOptions{Force: true})
1880 c.Assert(err, IsNil)
1881
1882 idx, err := w.r.Storer.Index()
1883 c.Assert(err, IsNil)
1884 c.Assert(idx.Entries, HasLen, 9)
1885
1886 err = util.WriteFile(w.Filesystem, "qux/qux", []byte("QUX"), 0755)
1887 c.Assert(err, IsNil)
1888 err = util.WriteFile(w.Filesystem, "qux/baz", []byte("BAZ"), 0755)
1889 c.Assert(err, IsNil)
1890 err = util.WriteFile(w.Filesystem, "qux/bar/baz", []byte("BAZ"), 0755)
1891 c.Assert(err, IsNil)
1892
1893 err = w.AddWithOptions(&AddOptions{Glob: w.Filesystem.Join("qux", "b*")})
1894 c.Assert(err, IsNil)
1895
1896 idx, err = w.r.Storer.Index()
1897 c.Assert(err, IsNil)
1898 c.Assert(idx.Entries, HasLen, 11)
1899
1900 e, err := idx.Entry("qux/baz")
1901 c.Assert(err, IsNil)
1902 c.Assert(e.Mode, Equals, filemode.Executable)
1903
1904 e, err = idx.Entry("qux/bar/baz")
1905 c.Assert(err, IsNil)
1906 c.Assert(e.Mode, Equals, filemode.Executable)
1907
1908 status, err := w.Status()
1909 c.Assert(err, IsNil)
1910 c.Assert(status, HasLen, 3)
1911
1912 file := status.File("qux/qux")
1913 c.Assert(file.Staging, Equals, Untracked)
1914 c.Assert(file.Worktree, Equals, Untracked)
1915
1916 file = status.File("qux/baz")
1917 c.Assert(file.Staging, Equals, Added)
1918 c.Assert(file.Worktree, Equals, Unmodified)
1919
1920 file = status.File("qux/bar/baz")
1921 c.Assert(file.Staging, Equals, Added)
1922 c.Assert(file.Worktree, Equals, Unmodified)
1923}
1924
1925func (s *WorktreeSuite) TestAddGlobErrorNoMatches(c *C) {
1926 r, _ := Init(memory.NewStorage(), memfs.New())

Callers

nothing calls this directly

Calls 7

CheckoutMethod · 0.95
AddWithOptionsMethod · 0.95
StatusMethod · 0.95
JoinMethod · 0.80
EntryMethod · 0.80
IndexMethod · 0.65
FileMethod · 0.45

Tested by

no test coverage detected