mirror of https://github.com/docker/docker-py.git
Merge branch 'levin-du-develop'
This commit is contained in:
commit
9260f5af18
|
@ -143,7 +143,8 @@ 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,12 +61,16 @@ 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:
|
||||||
f.write("this file should not be ignored")
|
f.write("this file should not be ignored")
|
||||||
|
|
||||||
|
with open(os.path.join(base_dir, '#file.txt'), 'w') as f:
|
||||||
|
f.write('this file should not be ignored')
|
||||||
|
|
||||||
subdir = os.path.join(base_dir, 'ignored', 'subdir')
|
subdir = os.path.join(base_dir, 'ignored', 'subdir')
|
||||||
os.makedirs(subdir)
|
os.makedirs(subdir)
|
||||||
with open(os.path.join(subdir, 'file'), 'w') as f:
|
with open(os.path.join(subdir, 'file'), 'w') as f:
|
||||||
|
@ -92,6 +96,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
||||||
logs = logs.decode('utf-8')
|
logs = logs.decode('utf-8')
|
||||||
|
|
||||||
assert sorted(list(filter(None, logs.split('\n')))) == sorted([
|
assert sorted(list(filter(None, logs.split('\n')))) == sorted([
|
||||||
|
'/test/#file.txt',
|
||||||
'/test/ignored/subdir/excepted-file',
|
'/test/ignored/subdir/excepted-file',
|
||||||
'/test/not-ignored'
|
'/test/not-ignored'
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in New Issue