diff options
author | Matthew Suozzo <matthew.suozzo@gmail.com> | 2024-01-11 10:06:26 -0800 |
---|---|---|
committer | Matthew Suozzo <msuozzo@google.com> | 2024-01-12 11:18:37 -0500 |
commit | 86d3f41c8eb5939f384d30667f6097d716c1e916 (patch) | |
tree | 54d38c228c5057e920bc27069d8b94bb0892fb19 /worktree_test.go | |
parent | a6e934f1f76996c7f92cb4fde708170c1eb5d032 (diff) | |
download | go-git-86d3f41c8eb5939f384d30667f6097d716c1e916.tar.gz |
git: add option approximating git clean -x.
Diffstat (limited to 'worktree_test.go')
-rw-r--r-- | worktree_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/worktree_test.go b/worktree_test.go index 5759ec4..c00d630 100644 --- a/worktree_test.go +++ b/worktree_test.go @@ -2204,6 +2204,45 @@ func (s *WorktreeSuite) TestClean(c *C) { c.Assert(err, ErrorMatches, ".*(no such file or directory.*|.*file does not exist)*.") } +func (s *WorktreeSuite) TestCleanAll(c *C) { + fs := fixtures.Basic().ByTag("worktree").One().Worktree() + r, err := PlainOpen(fs.Root()) + c.Assert(err, IsNil) + w, err := r.Worktree() + c.Assert(err, IsNil) + + err = util.WriteFile(w.Filesystem, ".gitignore", []byte("foo\n"), 0755) + c.Assert(err, IsNil) + + _, err = w.Add(".") + c.Assert(err, IsNil) + + commitOpts := &CommitOptions{Author: &object.Signature{Name: "foo", Email: "foo@foo.foo", When: time.Now()}} + _, err = w.Commit("Add gitignore", commitOpts) + c.Assert(err, IsNil) + + status, err := w.Status() + c.Assert(err, IsNil) + c.Assert(len(status), Equals, 0) + + err = util.WriteFile(w.Filesystem, "foo", []byte("foo\n"), 0755) + c.Assert(err, IsNil) + + status, err = w.Status() + c.Assert(err, IsNil) + c.Assert(len(status), Equals, 0) + + err = w.Clean(&CleanOptions{All: true, Dir: true}) + c.Assert(err, IsNil) + + status, err = w.Status() + c.Assert(err, IsNil) + c.Assert(len(status), Equals, 0) + + _, err = fs.Lstat("foo") + c.Assert(err, ErrorMatches, ".*(no such file or directory.*|.*file does not exist)*.") +} + func (s *WorktreeSuite) TestCleanBare(c *C) { storer := memory.NewStorage() |