Skip to content

Commit fc6773d

Browse files
vmlintu-nostoshin-
authored andcommitted
Commit d798afc made changes for the handling of '**' patterns in
.dockerignore. This causes an IndexError with patterns ending with '**', e.g. 'subdir/**'. This adds a missing boundary check before checking for trailing '/'. Signed-off-by: Veli-Matti Lintu <[email protected]>
1 parent ba7580d commit fc6773d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

docker/utils/fnmatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def translate(pat):
7575
# is some flavor of "**"
7676
i = i + 1
7777
# Treat **/ as ** so eat the "/"
78-
if pat[i] == '/':
78+
if i < n and pat[i] == '/':
7979
i = i + 1
8080
if i >= n:
8181
# is "**EOF" - to align with .gitignore just accept all

tests/unit/utils_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,23 @@ def test_single_and_double_wildcard(self):
874874
)
875875
)
876876

877+
def test_trailing_double_wildcard(self):
878+
assert self.exclude(['subdir/**']) == convert_paths(
879+
self.all_paths - set(
880+
['subdir/file.txt',
881+
'subdir/target/file.txt',
882+
'subdir/target/subdir/file.txt',
883+
'subdir/subdir2/file.txt',
884+
'subdir/subdir2/target/file.txt',
885+
'subdir/subdir2/target/subdir/file.txt',
886+
'subdir/target',
887+
'subdir/target/subdir',
888+
'subdir/subdir2',
889+
'subdir/subdir2/target',
890+
'subdir/subdir2/target/subdir']
891+
)
892+
)
893+
877894

878895
class TarTest(unittest.TestCase):
879896
def test_tar_with_excludes(self):

0 commit comments

Comments
 (0)