From 0167dabb78412ed5fb76cb4b174a6708c3be52b8 Mon Sep 17 00:00:00 2001 From: kuba-- Date: Fri, 24 Aug 2018 23:44:44 +0200 Subject: Remove empty dirs when cleaning with Dir opt. Signed-off-by: kuba-- --- worktree_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'worktree_test.go') diff --git a/worktree_test.go b/worktree_test.go index df191b0..c714011 100644 --- a/worktree_test.go +++ b/worktree_test.go @@ -1591,6 +1591,10 @@ func (s *WorktreeSuite) TestClean(c *C) { c.Assert(len(status), Equals, 1) + fi, err := fs.Lstat("pkgA") + c.Assert(err, IsNil) + c.Assert(fi.IsDir(), Equals, true) + // Clean with Dir: true. err = wt.Clean(&CleanOptions{Dir: true}) c.Assert(err, IsNil) @@ -1599,6 +1603,11 @@ func (s *WorktreeSuite) TestClean(c *C) { c.Assert(err, IsNil) c.Assert(len(status), Equals, 0) + + // An empty dir should be deleted, as well. + _, err = fs.Lstat("pkgA") + c.Assert(err, ErrorMatches, ".*(no such file or directory.*|.*file does not exist)*.") + } func (s *WorktreeSuite) TestAlternatesRepo(c *C) { -- cgit