浏览代码

[gerrit_util] Configure new auth automatically

Because running git cl creds-check in every single repo is poor UX for
early dogfooders.

Bug: b/348024314
Change-Id: Ib5641418de7fa5a55a7f67b7069e63c04403852a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5660338
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
Allen Li 1 年之前
父节点
当前提交
6a00e594c9
共有 1 个文件被更改,包括 20 次插入0 次删除
  1. 20 0
      git_cl.py

+ 20 - 0
git_cl.py

@@ -2306,6 +2306,26 @@ class Changelist(object):
                 })
             return
 
+        if newauth.Enabled():
+            latestVer = 1
+            v: int = 0
+            try:
+                v = int(
+                    scm.GIT.GetConfig(settings.GetRoot(),
+                                      'depot-tools.gitauthautoconfigured',
+                                      default='0'))
+            except ValueError:
+                v = 0
+            if v < latestVer:
+                logging.debug(
+                    'Automatically configuring Git repo authentication (current version: %r, latest: %r)',
+                    v, latestVer)
+                ConfigureGitRepoAuth()
+                scm.GIT.SetConfig(settings.GetRoot(),
+                                  'depot-tools.gitAuthAutoConfigured',
+                                  str(latestVer))
+            return
+
         # Lazy-loader to identify Gerrit and Git hosts.
         self.GetCodereviewServer()
         git_host = self._GetGitHost()