Changed naming convention

presubmit:gerrit_host/folder/to/repo:path/to/file/:CheckName
Example
presubmit:chromium-review.googlesource.com/chromium/src/:services/viz/

Bug: 1112667
Change-Id: I095a2c04e73c64d67fa1bb3dbf7e6dfd1d93fe26
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2335873
Reviewed-by: Nodir Turakulov <nodir@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Saagar Sanghavi <saagarsanghavi@google.com>
diff --git a/presubmit_support.py b/presubmit_support.py
index e44b739..7ef84d1 100755
--- a/presubmit_support.py
+++ b/presubmit_support.py
@@ -1497,8 +1497,8 @@
   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 @@
     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 @@
 
     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 @@
             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 @@
         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 @@
                       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 @@
     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 @@
                       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 @@
           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)