Skip to content

Commit 7f5739d

Browse files
committed
Leading slash in .dockerignore should be ignored
Signed-off-by: Joffrey F <[email protected]>
1 parent 7139e2d commit 7f5739d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

docker/utils/build.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def exclude_paths(root, patterns, dockerfile=None):
2626
if dockerfile is None:
2727
dockerfile = 'Dockerfile'
2828

29+
patterns = [p.lstrip('/') for p in patterns]
2930
exceptions = [p for p in patterns if p.startswith('!')]
3031

3132
include_patterns = [p[1:] for p in exceptions]

tests/unit/utils_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,11 @@ def test_single_subdir_single_filename(self):
768768
self.all_paths - set(['foo/a.py'])
769769
)
770770

771+
def test_single_subdir_single_filename_leading_slash(self):
772+
assert self.exclude(['/foo/a.py']) == convert_paths(
773+
self.all_paths - set(['foo/a.py'])
774+
)
775+
771776
def test_single_subdir_with_path_traversal(self):
772777
assert self.exclude(['foo/whoops/../a.py']) == convert_paths(
773778
self.all_paths - set(['foo/a.py'])

0 commit comments

Comments
 (0)