Skip to content

Commit ac03724

Browse files
author
SakoPak
committed
exclude venv from scan
1 parent a865d72 commit ac03724

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/azure-cli/azure/cli/command_modules/acr/_archive_utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def _ignore_check(tarinfo, parent_ignored, parent_matching_rule_index):
106106
arcname="",
107107
parent_ignored=False,
108108
parent_matching_rule_index=ignore_list_size,
109-
ignore_check=_ignore_check)
109+
ignore_check=_ignore_check,
110+
build_ignore_dirs=build_ignore_dirs)
110111

111112
# Add the Dockerfile if it's specified.
112113
# In the case of run, there will be no Dockerfile.
@@ -188,7 +189,8 @@ def _load_dockerignore_file(source_location, original_docker_file_name):
188189
return ignore_list, len(ignore_list)
189190

190191

191-
def _archive_file_recursively(tar, name, arcname, parent_ignored, parent_matching_rule_index, ignore_check):
192+
def _archive_file_recursively(tar, name, arcname, parent_ignored, parent_matching_rule_index,
193+
ignore_check, build_ignore_dirs):
192194
# create a TarInfo object from the file
193195
tarinfo = tar.gettarinfo(name, arcname)
194196

@@ -208,11 +210,12 @@ def _archive_file_recursively(tar, name, arcname, parent_ignored, parent_matchin
208210
tar.addfile(tarinfo)
209211

210212
# even the dir is ignored, its child items can still be included, so continue to scan
211-
if tarinfo.isdir():
213+
# Exception: Skip scanning performance-impacting directories entirely
214+
if tarinfo.isdir() and not (ignored and os.path.basename(tarinfo.name) in build_ignore_dirs):
212215
for f in os.listdir(name):
213216
_archive_file_recursively(tar, os.path.join(name, f), os.path.join(arcname, f),
214217
parent_ignored=ignored, parent_matching_rule_index=matching_rule_index,
215-
ignore_check=ignore_check)
218+
ignore_check=ignore_check, build_ignore_dirs=build_ignore_dirs)
216219

217220

218221
def check_remote_source_code(source_location):

0 commit comments

Comments
 (0)