diff options
author | Joffrey F <joffrey@docker.com> | 2018-03-05 11:50:11 -0800 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2018-03-05 11:50:11 -0800 |
commit | 9260f5af18816522fee75082b53381fac1c5d00c (patch) | |
tree | 57dc50d4dc906af1bf650ac08f1c2a7b72847462 | |
parent | 9b8e022fa1012cae381bb97823e30936877c57c3 (diff) | |
parent | 13609359acfc33c42bda35ad240c4a8d96df13d4 (diff) | |
download | docker-py-9260f5af18816522fee75082b53381fac1c5d00c.tar.gz |
Merge branch 'levin-du-develop'
-rw-r--r-- | docker/api/build.py | 3 | ||||
-rw-r--r-- | tests/integration/api_build_test.py | 7 |
2 files changed, 8 insertions, 2 deletions
diff --git a/docker/api/build.py b/docker/api/build.py index 56f1fcf..e136a6e 100644 --- a/docker/api/build.py +++ b/docker/api/build.py @@ -143,7 +143,8 @@ class BuildApiMixin(object): if os.path.exists(dockerignore): with open(dockerignore, 'r') as f: 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( path, exclude=exclude, dockerfile=dockerfile, gzip=gzip diff --git a/tests/integration/api_build_test.py b/tests/integration/api_build_test.py index 4c2b992..ce587d5 100644 --- a/tests/integration/api_build_test.py +++ b/tests/integration/api_build_test.py @@ -61,12 +61,16 @@ class BuildTest(BaseAPIIntegrationTest): 'Dockerfile', '.dockerignore', '!ignored/subdir/excepted-file', - '', # empty line + '', # empty line, + '#*', # comment line ])) with open(os.path.join(base_dir, 'not-ignored'), 'w') as f: 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') os.makedirs(subdir) with open(os.path.join(subdir, 'file'), 'w') as f: @@ -92,6 +96,7 @@ class BuildTest(BaseAPIIntegrationTest): logs = logs.decode('utf-8') assert sorted(list(filter(None, logs.split('\n')))) == sorted([ + '/test/#file.txt', '/test/ignored/subdir/excepted-file', '/test/not-ignored' ]) |