Skip to content

Commit 3b464f9

Browse files
committed
Skip entirely excluded directories when handling dockerignore.
This is pure optimization to not recurse into directories when there are no chances any file will be included. Signed-off-by: mefyl <[email protected]>
1 parent bb3ad64 commit 3b464f9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docker/utils/build.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ def match(p):
9191
matched = default if hit is None else hit
9292
sub = list(filter(lambda p: p[1], sub))
9393
if os.path.isdir(cur):
94+
# Entirely skip directories if there are no chance any subfile will
95+
# be included.
96+
if all(not p[0] for p in sub) and not matched:
97+
continue
9498
children = False
9599
for r in (os.path.join(f, p) for p in walk(cur, sub, matched)):
96100
yield r

0 commit comments

Comments
 (0)