Skip to content

Commit

Permalink
Merge pull request #281 from ojohnny/only-ignore-relpath
Browse files Browse the repository at this point in the history
Only ignore relpaths, not entire paths
  • Loading branch information
jacebrowning committed Sep 26, 2017
2 parents 9986d45 + ad32cbe commit 949dc52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
14 changes: 4 additions & 10 deletions doorstop/core/vcs/base.py
Expand Up @@ -22,7 +22,6 @@ def __init__(self, path):
self.path = path
self._ignores_cache = None
self._path_cache = None
self._show_ci_warning = True

@staticmethod
def relpath(path):
Expand Down Expand Up @@ -90,24 +89,19 @@ def paths(self):
for dirpath, _, filenames in os.walk(self.path):
for filename in filenames:
path = os.path.join(dirpath, filename)
relpath = os.path.relpath(path, self.path)
# Skip ignored paths
if self.ignored(path):
if self.ignored(relpath):
continue
# Skip hidden paths
if os.path.sep + '.' in path:
if os.path.sep + '.' in relpath:
continue
relpath = os.path.relpath(path, self.path)
self._path_cache.append((path, filename, relpath))
yield from self._path_cache

def ignored(self, path):
"""Determine if a path matches an ignored pattern."""
for pattern in self.ignores:
if fnmatch.fnmatch(path, pattern):
if pattern == '*build*' and os.getenv('CI'):
if self._show_ci_warning:
log.critical("cannot ignore 'build' on the CI server")
self._show_ci_warning = False
else:
return True
return True
return False
8 changes: 0 additions & 8 deletions doorstop/core/vcs/tests/test_base.py
Expand Up @@ -42,11 +42,3 @@ def test_ignored(self):
self.assertFalse(self.wc.ignored("not_ignored.txt"))
self.assertTrue(self.wc.ignored("path/to/published.html"))
self.assertTrue(self.wc.ignored("build/path/to/anything"))

@patch('os.environ', {'CI': 'true'})
def test_ignored_on_ci(self):
"""Verify the build directory is not ignored during CI."""
self.assertTrue(self.wc.ignored("ignored.txt"))
self.assertFalse(self.wc.ignored("not_ignored.txt"))
self.assertTrue(self.wc.ignored("path/to/published.html"))
self.assertFalse(self.wc.ignored("build/path/to/anything"))

0 comments on commit 949dc52

Please sign in to comment.