Forráskód Böngészése

use ls-file to calculate all submodules instead of git submodule status

reason: git submodule status command could be slower and output may
not be deterministic depending on the init status and current status

Change-Id: I3c9b8128e6fb230d51eb456234396a557b61c86f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5528758
Auto-Submit: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Yiwei Zhang 1 éve
szülő
commit
a9b9284faf
1 módosított fájl, 15 hozzáadás és 6 törlés
  1. 15 6
      gclient.py

+ 15 - 6
gclient.py

@@ -4201,12 +4201,21 @@ def CMDsetdep(parser, args):
     if (not is_cog and 'git_dependencies' in local_scope
             and local_scope['git_dependencies']
             in (gclient_eval.SUBMODULES, gclient_eval.SYNC)):
-        try:
-            submodule_status = subprocess2.check_output(
-                ['git', 'submodule', 'status'], cwd=cwd).decode('utf-8')
-            git_modules = {l.split()[1] for l in submodule_status.splitlines()}
-        except subprocess2.CalledProcessError as e:
-            print('Warning: gitlinks won\'t be updated: ', e)
+        cmd = ['git', 'ls-files', '--format=%(objectmode) %(path)']
+        with subprocess2.Popen(
+                cmd,
+                cwd=cwd,
+                stdout=subprocess2.PIPE,
+                stderr=None if options.verbose else subprocess2.DEVNULL,
+                text=True) as p:
+            git_modules = {
+                line.split()[1].strip()
+                for line in p.stdout if line.startswith('160000')
+            }
+        if p.returncode != 0:
+            print('Warning: gitlinks won\'t be updated because computing '
+                  'submodules has failed.')
+            git_modules = None
 
     for var in options.vars:
         name, _, value = var.partition('=')