Commit 2a229719 authored by Aleksey Khoroshilov's avatar Aleksey Khoroshilov Committed by LUCI CQ

Improve codereview.settings file lookup.

Remove unnecessary os.listdir call and fix infinite loop on Windows if
no file was found in a tree.

Change-Id: I82a8763e807bbc0ce6fcae6b35a370ffe3b34943
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3687234Reviewed-by: 's avatarJosip Sokcevic <sokcevic@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Auto-Submit: Aleksey Khoroshilov <akhoroshilov@brave.com>
parent 8f1fea02
......@@ -3003,14 +3003,18 @@ def FindCodereviewSettingsFile(filename='codereview.settings'):
cwd = os.getcwd()
root = settings.GetRoot()
if os.path.isfile(os.path.join(root, inherit_ok_file)):
root = '/'
root = None
while True:
if filename in os.listdir(cwd):
if os.path.isfile(os.path.join(cwd, filename)):
return open(os.path.join(cwd, filename))
if os.path.isfile(os.path.join(cwd, filename)):
return open(os.path.join(cwd, filename))
if cwd == root:
break
cwd = os.path.dirname(cwd)
parent_dir = os.path.dirname(cwd)
if parent_dir == cwd:
# We hit the system root directory.
break
cwd = parent_dir
return None
def LoadCodereviewSettingsFromFile(fileobj):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment