summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVeli-Matti Lintu <veli-matti.lintu@nosto.com>2017-08-18 11:48:09 +0300
committerJoffrey F <f.joffrey@gmail.com>2017-08-22 17:00:11 -0700
commitfc6773d6732a433bda71dde24712584b7885deb8 (patch)
tree4b489686e1fee257f3c00973783534eff911347a
parentba7580d6b94324b7fe97e90e3f40693a12f5ce2c (diff)
downloaddocker-py-fc6773d6732a433bda71dde24712584b7885deb8.tar.gz
Commit d798afca 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 <veli-matti.lintu@nosto.com>
-rw-r--r--docker/utils/fnmatch.py2
-rw-r--r--tests/unit/utils_test.py17
2 files changed, 18 insertions, 1 deletions
diff --git a/docker/utils/fnmatch.py b/docker/utils/fnmatch.py
index e51bd81..42461dd 100644
--- a/docker/utils/fnmatch.py
+++ b/docker/utils/fnmatch.py
@@ -75,7 +75,7 @@ def translate(pat):
# is some flavor of "**"
i = i + 1
# Treat **/ as ** so eat the "/"
- if pat[i] == '/':
+ if i < n and pat[i] == '/':
i = i + 1
if i >= n:
# is "**EOF" - to align with .gitignore just accept all
diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py
index 4a391fa..2fa1d05 100644
--- a/tests/unit/utils_test.py
+++ b/tests/unit/utils_test.py
@@ -874,6 +874,23 @@ class ExcludePathsTest(unittest.TestCase):
)
)
+ def test_trailing_double_wildcard(self):
+ assert self.exclude(['subdir/**']) == convert_paths(
+ self.all_paths - set(
+ ['subdir/file.txt',
+ 'subdir/target/file.txt',
+ 'subdir/target/subdir/file.txt',
+ 'subdir/subdir2/file.txt',
+ 'subdir/subdir2/target/file.txt',
+ 'subdir/subdir2/target/subdir/file.txt',
+ 'subdir/target',
+ 'subdir/target/subdir',
+ 'subdir/subdir2',
+ 'subdir/subdir2/target',
+ 'subdir/subdir2/target/subdir']
+ )
+ )
+
class TarTest(unittest.TestCase):
def test_tar_with_excludes(self):