Skip to content

Commit

Permalink
Leading slash in .dockerignore should be ignored
Browse files Browse the repository at this point in the history
Signed-off-by: Joffrey F <[email protected]>
  • Loading branch information
shin- committed Aug 15, 2017
1 parent 5e4a69b commit 92a2e48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions docker/utils/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def exclude_paths(root, patterns, dockerfile=None):
if dockerfile is None:
dockerfile = 'Dockerfile'

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

include_patterns = [p[1:] for p in exceptions]
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,11 @@ def test_single_subdir_single_filename(self):
self.all_paths - set(['foo/a.py'])
)

def test_single_subdir_single_filename_leading_slash(self):
assert self.exclude(['/foo/a.py']) == convert_paths(
self.all_paths - set(['foo/a.py'])
)

def test_single_subdir_with_path_traversal(self):
assert self.exclude(['foo/whoops/../a.py']) == convert_paths(
self.all_paths - set(['foo/a.py'])
Expand Down

0 comments on commit 92a2e48

Please sign in to comment.