Jelajahi Sumber

[git_auth] Move config wizard to creds-check

Bug: b/404613530
Change-Id: Ie0b8fd675b66739a129d5eeeda895473a8a49eeb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6368999
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Allen Li 5 bulan lalu
induk
melakukan
a2c6f107c3
2 mengubah file dengan 7 tambahan dan 48 penghapusan
  1. 0 11
      git_auth.py
  2. 7 37
      git_cl.py

+ 0 - 11
git_auth.py

@@ -375,17 +375,6 @@ class ConfigWizard(object):
         self._println(
         self._println(
             '(Report any issues to https://issues.chromium.org/issues/new?component=1456702&template=2076315)'
             '(Report any issues to https://issues.chromium.org/issues/new?component=1456702&template=2076315)'
         )
         )
-        if not newauth.Enabled():
-            self._println()
-            self._println('You have not enabled new auth.')
-            self._println('This tool will configure Git to use new auth,')
-            self._println('while depot_tools will continue to use old auth.')
-            self._println(
-                "We recommend not continuing, though you may if you're adventurous."
-            )
-            self._println('(It will probably work.  Maybe.)')
-            if not self._ui.read_yn('Continue?', default=False):
-                return
         self._println()
         self._println()
         self._fix_gitcookies()
         self._fix_gitcookies()
         self._println()
         self._println()

+ 7 - 37
git_cl.py

@@ -3904,27 +3904,13 @@ def CMDcreds_check(parser, args):
 
 
     if newauth.Enabled():
     if newauth.Enabled():
         cl = Changelist()
         cl = Changelist()
-        host = cl.GetGerritHost()
-        print(f'Using Gerrit host: {host!r}')
-        git_auth.Configure(os.getcwd(), cl)
-        # Perform some advisory checks
-        email = scm.GIT.GetConfig(os.getcwd(), 'user.email') or ''
-        print(f'Using email (configured in Git): {email!r}')
-        if gerrit_util.ShouldUseSSO(host, email):
-            print('Detected that we should be using SSO.')
-        else:
-            print('Detected that we should be using git-credential-luci.')
-            a = gerrit_util.GitCredsAuthenticator()
-            try:
-                a.luci_auth.get_access_token()
-            except auth.GitLoginRequiredError as e:
-                print('NOTE: You are not logged in with git-credential-luci.')
-                print(
-                    'You will not be able to perform many actions without logging in.'
-                )
-                print('If you wish to log in, run:')
-                print('   ' + e.login_command)
-                print('and re-run this command.')
+        try:
+            remote_url = cl.GetRemoteUrl()
+        except subprocess2.CalledProcessError:
+            remote_url = ''
+        wizard = git_auth.ConfigWizard(
+            git_auth.UserInterface(sys.stdin, sys.stdout))
+        wizard.run(remote_url)
         return 0
         return 0
     if newauth.ExplicitlyDisabled():
     if newauth.ExplicitlyDisabled():
         git_auth.ClearRepoConfig(os.getcwd(), Changelist())
         git_auth.ClearRepoConfig(os.getcwd(), Changelist())
@@ -3955,22 +3941,6 @@ def CMDcreds_check(parser, args):
     return 1
     return 1
 
 
 
 
-def CMDcreds_check2(parser, args):
-    """Checks credentials and suggests changes.
-
-    New wizard version, currently for testing use.
-    """
-    _, _ = parser.parse_args(args)
-    cl = Changelist()
-    try:
-        remote_url = cl.GetRemoteUrl()
-    except subprocess2.CalledProcessError:
-        remote_url = ''
-    wizard = git_auth.ConfigWizard(git_auth.UserInterface(
-        sys.stdin, sys.stdout))
-    wizard.run(remote_url)
-
-
 @metrics.collector.collect_metrics('git cl baseurl')
 @metrics.collector.collect_metrics('git cl baseurl')
 def CMDbaseurl(parser, args):
 def CMDbaseurl(parser, args):
     """Gets or sets base-url for this branch."""
     """Gets or sets base-url for this branch."""