Commits

Anonymous committed 4476630

project: ? and * in ignored patterns do not match slashes

Comments (0)

Files changed (3)

rope/base/default_config.py

 
     # Specify which files and folders to ignore in the project.
     # Changes to ignored resources are not added to the history and
-    # VCSs.  Also they are not shown in "Find File" dialog.
+    # VCSs.  Also they are not returned in `Project.get_files()`.
+    # Note that ``?`` and ``*`` match all characters but slashes.
     prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject',
                                   '.hg', '.svn', '_svn']
 

rope/base/project.py

 
     def _add_ignored_pattern(self, pattern):
         re_pattern = pattern.replace('.', '\\.').\
-                     replace('*', '.*').replace('?', '.')
+                     replace('*', '[^/]*').replace('?', '[^/]')
         re_pattern = '(.*/)?' + re_pattern + '(/.*)?'
         self.ignored_patterns.append(re.compile(re_pattern))
 

ropetest/projecttest.py

         self.assertTrue(self.project.is_ignored(myfile))
         self.assertFalse(self.project.is_ignored(file2))
 
+    def test_star_should_not_include_slashes(self):
+        self.project = testutils.sample_project(ignored_resources=['f*.txt'])
+        folder = self.project.root.create_folder('folder')
+        file1 = folder.create_file('myfile.txt')
+        file2 = folder.create_file('file2.txt')
+        self.assertFalse(self.project.is_ignored(file1))
+        self.assertTrue(self.project.is_ignored(file2))
+
     def test_normal_fscommands(self):
         fscommands = _MockFSCommands()
         self.project = testutils.sample_project(fscommands=fscommands)