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
changes/00/373500/1
tobiasjs 9 years ago committed by Commit bot
parent bd604a16cb
commit ff061c0d1d

@ -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

Loading…
Cancel
Save