| 
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -1497,8 +1497,8 @@ def DoPostUploadExecuter(change,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  return exit_code
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				class PresubmitExecuter(object):
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  def __init__(self, change, committing, verbose,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				               gerrit_obj, dry_run=None, thread_pool=None, parallel=False):
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  def __init__(self, change, committing, verbose, gerrit_obj, dry_run=None,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				               thread_pool=None, parallel=False, gerrit_project=None):
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    """
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    Args:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      change: The Change object.
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -1516,6 +1516,7 @@ class PresubmitExecuter(object):
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    self.more_cc = []
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    self.thread_pool = thread_pool
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    self.parallel = parallel
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    self.gerrit_project = gerrit_project
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  def ExecPresubmitScript(self, script_text, presubmit_path):
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    """Executes a single presubmit script.
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -1555,12 +1556,21 @@ class PresubmitExecuter(object):
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    context['__args'] = (input_api, output_api)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    # Get path of presubmit directory relative to repository root
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    # Get path of presubmit directory relative to repository root.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    # Always use forward slashes, so that path is same in *nix and Windows
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    root = input_api.change.RepositoryRoot()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    rel_path = os.path.relpath(presubmit_dir, root)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    rel_path = rel_path.replace(os.path.sep, '/')
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    # Get the URL of git remote origin and use it to identify host and project
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    host = ''
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if self.gerrit and self.gerrit.host:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      host = self.gerrit.host
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    project = self.gerrit_project or ''
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    # Prefix for test names
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    prefix = 'presubmit:%s/%s:%s/' % (host, project, rel_path)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    # Perform all the desired presubmit checks.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    results = []
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -1575,7 +1585,7 @@ class PresubmitExecuter(object):
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            continue
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          logging.debug('Running %s in %s', function_name, presubmit_path)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          results.extend(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				              self._run_check_function(function_name, context, rel_path))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				              self._run_check_function(function_name, context, prefix))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          logging.debug('Running %s done.', function_name)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          self.more_cc.extend(output_api.more_cc)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -1587,7 +1597,7 @@ class PresubmitExecuter(object):
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if function_name in context:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            logging.debug('Running %s in %s', function_name, presubmit_path)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            results.extend(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                self._run_check_function(function_name, context, rel_path))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                self._run_check_function(function_name, context, prefix))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            logging.debug('Running %s done.', function_name)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            self.more_cc.extend(output_api.more_cc)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -1636,7 +1646,8 @@ def DoPresubmitChecks(change,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                      gerrit_obj,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                      dry_run=None,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                      parallel=False,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                      json_output=None):
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                      json_output=None,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                      gerrit_project=None):
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  """Runs all presubmit checks that apply to the files in the change.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  This finds all PRESUBMIT.py files in directories enclosing the files in the
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -1679,7 +1690,7 @@ def DoPresubmitChecks(change,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    results = []
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    thread_pool = ThreadPool()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    executer = PresubmitExecuter(change, committing, verbose, gerrit_obj,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                 dry_run, thread_pool, parallel)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                 dry_run, thread_pool, parallel, gerrit_project)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if default_presubmit:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      if verbose:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        sys.stdout.write('Running default presubmit script.\n')
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -1923,7 +1934,7 @@ def main(argv=None):
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                      help='List of files to be marked as modified when '
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                      'executing presubmit or post-upload hooks. fnmatch '
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                      'wildcards can also be used.')
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  parser.add_argument('--gerrit_project', help=argparse.SUPPRESS)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  options = parser.parse_args(argv)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  log_level = logging.ERROR
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -1956,7 +1967,8 @@ def main(argv=None):
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          gerrit_obj,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          options.dry_run,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          options.parallel,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          options.json_output)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          options.json_output,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          options.gerrit_project)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  except PresubmitFailure as e:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    print(e, file=sys.stderr)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    print('Maybe your depot_tools is out of date?', file=sys.stderr)
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |