Przeglądaj źródła

Don't raise 'not a git repo' error in metrics collection.

Fixed: 1424809
Change-Id: I8f8b036a0ef1dd21a58d2af232e105b045e07f56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4343669
Commit-Queue: Joanna Wang <jojwang@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Joanna Wang 2 lat temu
rodzic
commit
c5b38329e6
1 zmienionych plików z 10 dodań i 4 usunięć
  1. 10 4
      git_cl.py

+ 10 - 4
git_cl.py

@@ -6224,10 +6224,16 @@ class OptionParser(optparse.OptionParser):
       settings = Settings()
       settings = Settings()
 
 
       if metrics.collector.config.should_collect_metrics:
       if metrics.collector.config.should_collect_metrics:
-        # GetViewVCUrl ultimately calls logging method.
-        project_url = settings.GetViewVCUrl().strip('/+')
-        if project_url in metrics_utils.KNOWN_PROJECT_URLS:
-          metrics.collector.add('project_urls', [project_url])
+        try:
+          # GetViewVCUrl ultimately calls logging method.
+          project_url = settings.GetViewVCUrl().strip('/+')
+          if project_url in metrics_utils.KNOWN_PROJECT_URLS:
+            metrics.collector.add('project_urls', [project_url])
+        except subprocess2.CalledProcessError:
+          # Occurs when command is not executed in a git repository
+          # We should not fail here. If the command needs to be executed
+          # in a repo, it will be raised later.
+          pass
 
 
   def _parse_args(self, args=None):
   def _parse_args(self, args=None):
     # Create an optparse.Values object that will store only the actual passed
     # Create an optparse.Values object that will store only the actual passed