Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1087)

Unified Diff: presubmit_support.py

Issue 2232203002: Support additional user presubmit scripts named PRESUBMIT*.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Correctly ignore PRESUBMIT_test.py and PRESUBMIT*.pyc Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | testing_support/super_mox.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_support.py
diff --git a/presubmit_support.py b/presubmit_support.py
index 807da4a05d1458751207f96cc02f8ff21a35cd10..2922b4e32938c873da53decfc4e646e9b8d73174 100755
--- a/presubmit_support.py
+++ b/presubmit_support.py
@@ -494,7 +494,7 @@ class InputApi(object):
local_path = affected_file.LocalPath()
for item in items:
if self.re.match(item, local_path):
- logging.debug("%s matched %s" % (item, local_path))
+ logging.debug("%s matched %s", item, local_path)
return True
return False
return (Find(affected_file, white_list or self.DEFAULT_WHITE_LIST) and
@@ -646,7 +646,7 @@ class AffectedFile(object):
self._cached_changed_contents = None
self._cached_new_contents = None
self._diff_cache = diff_cache
- logging.debug('%s(%s)' % (self.__class__.__name__, self._path))
+ logging.debug('%s(%s)', self.__class__.__name__, self._path)
def ServerPath(self):
"""Returns a path string that identifies the file in the SCM system.
@@ -1093,11 +1093,13 @@ def ListRelevantPresubmitFiles(files, root):
# Look for PRESUBMIT.py in all candidate directories.
results = []
for directory in sorted(list(candidates)):
- p = os.path.join(directory, 'PRESUBMIT.py')
- if os.path.isfile(p):
- results.append(p)
+ 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)
- logging.debug('Presubmit files: %s' % ','.join(results))
+ logging.debug('Presubmit files: %s', ','.join(results))
return results
@@ -1454,9 +1456,9 @@ class PresubmitExecuter(object):
function_name = 'CheckChangeOnUpload'
if function_name in context:
context['__args'] = (input_api, OutputApi(self.committing))
- logging.debug('Running %s in %s' % (function_name, presubmit_path))
+ logging.debug('Running %s in %s', function_name, presubmit_path)
result = eval(function_name + '(*__args)', context)
- logging.debug('Running %s done.' % function_name)
+ logging.debug('Running %s done.', function_name)
if not (isinstance(result, types.TupleType) or
isinstance(result, types.ListType)):
raise PresubmitFailure(
@@ -1609,7 +1611,7 @@ def ScanSubDirs(mask, recursive):
def ParseFiles(args, recursive):
- logging.debug('Searching for %s' % args)
+ logging.debug('Searching for %s', args)
files = []
for arg in args:
files.extend([('M', f) for f in ScanSubDirs(arg, recursive)])
@@ -1632,7 +1634,7 @@ def load_files(options, args):
if not files:
files = scm.GIT.CaptureStatus([], options.root, upstream)
else:
- logging.info('Doesn\'t seem under source control. Got %d files' % len(args))
+ logging.info('Doesn\'t seem under source control. Got %d files', len(args))
if not files:
return None, None
change_class = Change
@@ -1754,7 +1756,7 @@ def main(argv=None):
change_class, files = load_files(options, args)
if not change_class:
parser.error('For unversioned directory, <files> is not optional.')
- logging.info('Found %d file(s).' % len(files))
+ logging.info('Found %d file(s).', len(files))
rietveld_obj, gerrit_obj = None, None
« no previous file with comments | « no previous file | testing_support/super_mox.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698