def test_include_exclude_include(self):
     filter = IgnoreFilter([b"a.c", b"!a.c", b"a.c"])
     self.assertTrue(filter.is_ignored(b"a.c"))
     self.assertEqual(
         [Pattern(b"a.c"), Pattern(b"!a.c"), Pattern(b"a.c")],
         list(filter.find_matching(b"a.c")),
     )
Example #2
0
 def test_excluded(self):
     filter = IgnoreFilter([b'a.c', b'b.c', b'!c.c'])
     self.assertFalse(filter.is_ignored(b'c.c'))
     self.assertIs(None, filter.is_ignored(b'd.c'))
     self.assertEqual(
         [Pattern(b'!c.c')],
         list(filter.find_matching(b'c.c')))
     self.assertEqual([], list(filter.find_matching(b'd.c')))
 def test_stack_first(self):
     filter1 = IgnoreFilter([b'[a].c', b'[b].c', b'![d].c'])
     filter2 = IgnoreFilter([b'[a].c', b'![b],c', b'[c].c', b'[d].c'])
     stack = IgnoreFilterStack([filter1, filter2])
     self.assertIs(True, stack.is_ignored(b'a.c'))
     self.assertIs(True, stack.is_ignored(b'b.c'))
     self.assertIs(True, stack.is_ignored(b'c.c'))
     self.assertIs(False, stack.is_ignored(b'd.c'))
     self.assertIs(None, stack.is_ignored(b'e.c'))
 def test_stack_first(self):
     filter1 = IgnoreFilter([b"[a].c", b"[b].c", b"![d].c"])
     filter2 = IgnoreFilter([b"[a].c", b"![b],c", b"[c].c", b"[d].c"])
     stack = IgnoreFilterStack([filter1, filter2])
     self.assertIs(True, stack.is_ignored(b"a.c"))
     self.assertIs(True, stack.is_ignored(b"b.c"))
     self.assertIs(True, stack.is_ignored(b"c.c"))
     self.assertIs(False, stack.is_ignored(b"d.c"))
     self.assertIs(None, stack.is_ignored(b"e.c"))
 def test_included_ignorecase(self):
     filter = IgnoreFilter([b"a.c", b"b.c"], ignorecase=False)
     self.assertTrue(filter.is_ignored(b"a.c"))
     self.assertFalse(filter.is_ignored(b"A.c"))
     filter = IgnoreFilter([b"a.c", b"b.c"], ignorecase=True)
     self.assertTrue(filter.is_ignored(b"a.c"))
     self.assertTrue(filter.is_ignored(b"A.c"))
     self.assertTrue(filter.is_ignored(b"A.C"))
 def test_included_ignorecase(self):
     filter = IgnoreFilter([b'a.c', b'b.c'], ignorecase=False)
     self.assertTrue(filter.is_ignored(b'a.c'))
     self.assertFalse(filter.is_ignored(b'A.c'))
     filter = IgnoreFilter([b'a.c', b'b.c'], ignorecase=True)
     self.assertTrue(filter.is_ignored(b'a.c'))
     self.assertTrue(filter.is_ignored(b'A.c'))
     self.assertTrue(filter.is_ignored(b'A.C'))
 def test_manpage(self):
     # A specific example from the gitignore manpage
     filter = IgnoreFilter([b"/*", b"!/foo", b"/foo/*", b"!/foo/bar"])
     self.assertTrue(filter.is_ignored(b"a.c"))
     self.assertTrue(filter.is_ignored(b"foo/blie"))
     self.assertFalse(filter.is_ignored(b"foo"))
     self.assertFalse(filter.is_ignored(b"foo/bar"))
     self.assertFalse(filter.is_ignored(b"foo/bar/"))
     self.assertFalse(filter.is_ignored(b"foo/bar/bloe"))
 def test_manpage(self):
     # A specific example from the gitignore manpage
     filter = IgnoreFilter([b'/*', b'!/foo', b'/foo/*', b'!/foo/bar'])
     self.assertTrue(filter.is_ignored(b'a.c'))
     self.assertTrue(filter.is_ignored(b'foo/blie'))
     self.assertFalse(filter.is_ignored(b'foo'))
     self.assertFalse(filter.is_ignored(b'foo/bar'))
     self.assertFalse(filter.is_ignored(b'foo/bar/'))
     self.assertFalse(filter.is_ignored(b'foo/bar/bloe'))
Example #9
0
 def test_excluded(self):
     filter = IgnoreFilter([b"a.c", b"b.c", b"!c.c"])
     self.assertFalse(filter.is_ignored(b"c.c"))
     self.assertIs(None, filter.is_ignored(b"d.c"))
     self.assertEqual([Pattern(b"!c.c")],
                      list(filter.find_matching(b"c.c")))
     self.assertEqual([], list(filter.find_matching(b"d.c")))
 def test_excluded(self):
     filter = IgnoreFilter([b'a.c', b'b.c', b'!c.c'])
     self.assertFalse(filter.is_ignored(b'c.c'))
     self.assertIs(None, filter.is_ignored(b'd.c'))
     self.assertEqual([Pattern(b'!c.c')],
                      list(filter.find_matching(b'c.c')))
     self.assertEqual([], list(filter.find_matching(b'd.c')))
Example #11
0
 def test_included_ignorecase(self):
     filter = IgnoreFilter([b'a.c', b'b.c'], ignorecase=False)
     self.assertTrue(filter.is_ignored(b'a.c'))
     self.assertFalse(filter.is_ignored(b'A.c'))
     filter = IgnoreFilter([b'a.c', b'b.c'], ignorecase=True)
     self.assertTrue(filter.is_ignored(b'a.c'))
     self.assertTrue(filter.is_ignored(b'A.c'))
     self.assertTrue(filter.is_ignored(b'A.C'))
Example #12
0
 def test_manpage(self):
     # A specific example from the gitignore manpage
     filter = IgnoreFilter([
         b'/*',
         b'!/foo',
         b'/foo/*',
         b'!/foo/bar'])
     self.assertTrue(filter.is_ignored(b'a.c'))
     self.assertTrue(filter.is_ignored(b'foo/blie'))
     self.assertFalse(filter.is_ignored(b'foo'))
     self.assertFalse(filter.is_ignored(b'foo/bar'))
     self.assertFalse(filter.is_ignored(b'foo/bar/'))
     self.assertFalse(filter.is_ignored(b'foo/bar/bloe'))
Example #13
0
 def test_excluded(self):
     filter = IgnoreFilter([b'a.c', b'b.c', b'!c.c'])
     self.assertFalse(filter.is_ignored(b'c.c'))
     self.assertIs(None, filter.is_ignored(b'd.c'))
Example #14
0
 def test_include_exclude_include(self):
     filter = IgnoreFilter([b'a.c', b'!a.c', b'a.c'])
     self.assertTrue(filter.is_ignored(b'a.c'))
     self.assertEqual(
         [Pattern(b'a.c'), Pattern(b'!a.c'), Pattern(b'a.c')],
         list(filter.find_matching(b'a.c')))
Example #15
0
 def test_include_exclude_include(self):
     filter = IgnoreFilter([b'a.c', b'!a.c', b'a.c'])
     self.assertTrue(filter.is_ignored(b'a.c'))
 def test_regex_special(self):
     # See https://github.com/dulwich/dulwich/issues/930#issuecomment-1026166429
     filter = IgnoreFilter([b"/foo\\[bar\\]", b"/foo"])
     self.assertTrue(filter.is_ignored("foo"))
     self.assertTrue(filter.is_ignored("foo[bar]"))
 def test_include_exclude_include(self):
     filter = IgnoreFilter([b'a.c', b'!a.c', b'a.c'])
     self.assertTrue(filter.is_ignored(b'a.c'))
     self.assertEqual([Pattern(b'a.c'),
                       Pattern(b'!a.c'),
                       Pattern(b'a.c')], list(filter.find_matching(b'a.c')))
Example #18
0
 def test_included(self):
     filter = IgnoreFilter([b'a.c', b'b.c'])
     self.assertTrue(filter.is_ignored(b'a.c'))
     self.assertIs(None, filter.is_ignored(b'c.c'))