Skip to content

Commit

Permalink
Merge pull request sphinx-doc#6277 from tk0miya/6271_make_clean
Browse files Browse the repository at this point in the history
Fix sphinx-doc#6271: make clean is catastrophically broken if building into '.'
  • Loading branch information
tk0miya authored Apr 13, 2019
2 parents 91fac1a + d45c0d3 commit 11a4e47
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Features added
* #6232: Enable CLI override of Makefile variables
* #6212 autosummary: Add :confval:`autosummary_imported_members` to display
imported members on autosummary
* #6271: ``make clean`` is catastrophically broken if building into '.'

Bugs fixed
----------
Expand Down
8 changes: 8 additions & 0 deletions sphinx/cmd/make_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,19 @@ def builddir_join(self, *comps):

def build_clean(self):
# type: () -> int
srcdir = path.abspath(self.srcdir)
builddir = path.abspath(self.builddir)
if not path.exists(self.builddir):
return 0
elif not path.isdir(self.builddir):
print("Error: %r is not a directory!" % self.builddir)
return 1
elif srcdir == builddir:
print("Error: %r is same as source directory!" % self.builddir)
return 1
elif path.commonpath([srcdir, builddir]) == builddir:
print("Error: %r directory contains source directory!" % self.builddir)
return 1
print("Removing everything under %r..." % self.builddir)
for item in os.listdir(self.builddir):
rmtree(self.builddir_join(item))
Expand Down

0 comments on commit 11a4e47

Please sign in to comment.