Commit 23aba916 authored by Tim Heap's avatar Tim Heap

Fix #849 global-exclude globbing

After #764, `global-exclude .pyc` no longer excluded `.pyc` files.
This fixes that regression, and adds a test for this behaviour.
parent e8d53c0b
...@@ -457,7 +457,7 @@ class FileList(_FileList): ...@@ -457,7 +457,7 @@ class FileList(_FileList):
""" """
if self.allfiles is None: if self.allfiles is None:
self.findall() self.findall()
match = translate_pattern(os.path.join('**', pattern)) match = translate_pattern(os.path.join('**', '*' + pattern))
found = [f for f in self.allfiles if match.match(f)] found = [f for f in self.allfiles if match.match(f)]
self.extend(found) self.extend(found)
return bool(found) return bool(found)
...@@ -466,7 +466,7 @@ class FileList(_FileList): ...@@ -466,7 +466,7 @@ class FileList(_FileList):
""" """
Exclude all files anywhere that match the pattern. Exclude all files anywhere that match the pattern.
""" """
match = translate_pattern(os.path.join('**', pattern)) match = translate_pattern(os.path.join('**', '*' + pattern))
return self._remove_files(match.match) return self._remove_files(match.match)
def append(self, item): def append(self, item):
......
...@@ -449,6 +449,11 @@ class TestFileListTest(TempDirTestCase): ...@@ -449,6 +449,11 @@ class TestFileListTest(TempDirTestCase):
assert file_list.files == ['a.py', l('d/c.py')] assert file_list.files == ['a.py', l('d/c.py')]
self.assertWarnings() self.assertWarnings()
file_list.process_template_line('global-include .txt')
file_list.sort()
assert file_list.files == ['a.py', 'b.txt', l('d/c.py')]
self.assertNoWarnings()
def test_global_exclude(self): def test_global_exclude(self):
l = make_local_path l = make_local_path
# global-exclude # global-exclude
...@@ -465,6 +470,13 @@ class TestFileListTest(TempDirTestCase): ...@@ -465,6 +470,13 @@ class TestFileListTest(TempDirTestCase):
assert file_list.files == ['b.txt'] assert file_list.files == ['b.txt']
self.assertWarnings() self.assertWarnings()
file_list = FileList()
file_list.files = ['a.py', 'b.txt', l('d/c.pyc'), 'e.pyo']
file_list.process_template_line('global-exclude .py[co]')
file_list.sort()
assert file_list.files == ['a.py', 'b.txt']
self.assertNoWarnings()
def test_recursive_include(self): def test_recursive_include(self):
l = make_local_path l = make_local_path
# recursive-include # recursive-include
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment