Commit ff061c0d authored by tobiasjs's avatar tobiasjs Committed by Commit bot

Do not assume that all presubmit directories still exist.

In the case where a CL deletes the last file in the directory,
it is listed in the presubmit files list, but the directory to
which it refers will not exist, leading to os.listdir failing.

BUG=638343

Review-Url: https://codereview.chromium.org/2250353003
parent bd604a16
......@@ -1093,11 +1093,14 @@ def ListRelevantPresubmitFiles(files, root):
# Look for PRESUBMIT.py in all candidate directories.
results = []
for directory in sorted(list(candidates)):
for f in os.listdir(directory):
p = os.path.join(directory, f)
if os.path.isfile(p) and re.match(
r'PRESUBMIT.*\.py$', f) and not f.startswith('PRESUBMIT_test'):
results.append(p)
try:
for f in os.listdir(directory):
p = os.path.join(directory, f)
if os.path.isfile(p) and re.match(
r'PRESUBMIT.*\.py$', f) and not f.startswith('PRESUBMIT_test'):
results.append(p)
except OSError:
pass
logging.debug('Presubmit files: %s', ','.join(results))
return results
......
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