Skip to content

Commit 9260f5a

Browse files
committed
Merge branch 'levin-du-develop'
2 parents 9b8e022 + 1360935 commit 9260f5a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

docker/api/build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
143143
if os.path.exists(dockerignore):
144144
with open(dockerignore, 'r') as f:
145145
exclude = list(filter(
146-
bool, [l.strip() for l in f.read().splitlines()]
146+
lambda x: x != '' and x[0] != '#',
147+
[l.strip() for l in f.read().splitlines()]
147148
))
148149
context = utils.tar(
149150
path, exclude=exclude, dockerfile=dockerfile, gzip=gzip

tests/integration/api_build_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,16 @@ def test_build_with_dockerignore(self):
6161
'Dockerfile',
6262
'.dockerignore',
6363
'!ignored/subdir/excepted-file',
64-
'', # empty line
64+
'', # empty line,
65+
'#*', # comment line
6566
]))
6667

6768
with open(os.path.join(base_dir, 'not-ignored'), 'w') as f:
6869
f.write("this file should not be ignored")
6970

71+
with open(os.path.join(base_dir, '#file.txt'), 'w') as f:
72+
f.write('this file should not be ignored')
73+
7074
subdir = os.path.join(base_dir, 'ignored', 'subdir')
7175
os.makedirs(subdir)
7276
with open(os.path.join(subdir, 'file'), 'w') as f:
@@ -92,6 +96,7 @@ def test_build_with_dockerignore(self):
9296
logs = logs.decode('utf-8')
9397

9498
assert sorted(list(filter(None, logs.split('\n')))) == sorted([
99+
'/test/#file.txt',
95100
'/test/ignored/subdir/excepted-file',
96101
'/test/not-ignored'
97102
])

0 commit comments

Comments
 (0)