mirror of https://github.com/docker/docker-py.git
Ignore comment line from the .dockerignore file
This fixed the bug that test comment line in .dockerignore file as ignore rule bug. Add test for "# comment" patterns in .dockerignore. Signed-off-by: Wanzhi Du <wanzhi09@gmail.com>
This commit is contained in:
parent
9b8e022fa1
commit
7a28ff3510
|
|
@ -143,7 +143,7 @@ class BuildApiMixin(object):
|
||||||
if os.path.exists(dockerignore):
|
if os.path.exists(dockerignore):
|
||||||
with open(dockerignore, 'r') as f:
|
with open(dockerignore, 'r') as f:
|
||||||
exclude = list(filter(
|
exclude = list(filter(
|
||||||
bool, [l.strip() for l in f.read().splitlines()]
|
lambda x: x != '' and x[0] != '#', [l.strip() for l in f.read().splitlines()]
|
||||||
))
|
))
|
||||||
context = utils.tar(
|
context = utils.tar(
|
||||||
path, exclude=exclude, dockerfile=dockerfile, gzip=gzip
|
path, exclude=exclude, dockerfile=dockerfile, gzip=gzip
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ class BuildTest(BaseAPIIntegrationTest):
|
||||||
'Dockerfile',
|
'Dockerfile',
|
||||||
'.dockerignore',
|
'.dockerignore',
|
||||||
'!ignored/subdir/excepted-file',
|
'!ignored/subdir/excepted-file',
|
||||||
'', # empty line
|
'', # empty line,
|
||||||
|
'#', # comment line
|
||||||
]))
|
]))
|
||||||
|
|
||||||
with open(os.path.join(base_dir, 'not-ignored'), 'w') as f:
|
with open(os.path.join(base_dir, 'not-ignored'), 'w') as f:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue