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>
This commit is contained in:
Veli-Matti Lintu 2017-08-18 11:48:09 +03:00 committed by Joffrey F
parent ba7580d6b9
commit fc6773d673
2 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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):