Kaynağa Gözat

A pattern with only a trailing slash should be treated as a glob

A pattern like "bar/" should still ignore "foo/bar/", but "/bar/" should
not.
Segev Finer 7 yıl önce
ebeveyn
işleme
90d414f7ad
2 değiştirilmiş dosya ile 3 ekleme ve 1 silme
  1. 1 1
      dulwich/ignore.py
  2. 2 0
      dulwich/tests/test_ignore.py

+ 1 - 1
dulwich/ignore.py

@@ -36,7 +36,7 @@ def translate(pat):
 
     res = b'(?ms)'
 
-    if b'/' not in pat:
+    if b'/' not in pat[:-1]:
         # If there's no slash, this is a filename-based match
         res = res + b'(.*/)?'
 

+ 2 - 0
dulwich/tests/test_ignore.py

@@ -47,12 +47,14 @@ POSITIVE_MATCH_TESTS = [
     (b"bla.c", b"**/bla.c"),
     (b"foo/bar", b"foo/**/bar"),
     (b"foo/bla/bar", b"foo/**/bar"),
+    (b"foo/bar/", b"bar/"),
 ]
 
 NEGATIVE_MATCH_TESTS = [
     (b"foo.c", b"foo.[dh]"),
     (b"foo/foo.c", b"/foo.c"),
     (b"foo/foo.c", b"/*.c"),
+    (b"foo/bar/", b"/bar/"),
 ]