Allow to skip EnsureAuthenticated for Gerrit.
Adding this line to codereview.settings should do the trick:
GERRIT_SKIP_ENSURE_AUTHENTICATED: true
And I also cleaned up tests so they don't spill too much to stdout.
BUG=603378
R=machenbach@chromium.org,andybons@chromium.org
CC=shinyak@chromium.org
Review URL: https://codereview.chromium.org/1884173003
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299926 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl.py b/git_cl.py
index 9bc7d52..eb66039 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -589,6 +589,7 @@
self.updated = False
self.is_gerrit = None
self.squash_gerrit_uploads = None
+ self.gerrit_skip_ensure_authenticated = None
self.git_editor = None
self.project = None
self.force_https_commit_url = None
@@ -771,6 +772,15 @@
error_ok=True).strip() == 'true')
return self.squash_gerrit_uploads
+ def GetGerritSkipEnsureAuthenticated(self):
+ """Return True if EnsureAuthenticated should not be done for Gerrit
+ uploads."""
+ if self.gerrit_skip_ensure_authenticated is None:
+ self.gerrit_skip_ensure_authenticated = (
+ RunGit(['config', '--bool', 'gerrit.skip_ensure_authenticated'],
+ error_ok=True).strip() == 'true')
+ return self.gerrit_skip_ensure_authenticated
+
def GetGitEditor(self):
"""Return the editor specified in the git config, or None if none is."""
if self.git_editor is None:
@@ -2022,6 +2032,10 @@
def EnsureAuthenticated(self, force):
"""Best effort check that user is authenticated with Gerrit server."""
+ if settings.GetGerritSkipEnsureAuthenticated():
+ # For projects with unusual authentication schemes.
+ # See http://crbug.com/603378.
+ return
# Lazy-loader to identify Gerrit and Git hosts.
if gerrit_util.GceAuthenticator.is_gce():
return
@@ -2717,6 +2731,10 @@
RunGit(['config', 'gerrit.squash-uploads',
keyvals['GERRIT_SQUASH_UPLOADS']])
+ if 'GERRIT_SKIP_ENSURE_AUTHENTICATED' in keyvals:
+ RunGit(['config', 'gerrit.skip_ensure_authenticated',
+ keyvals['GERRIT_SKIP_ENSURE_AUTHENTICATED']])
+
if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals:
#should be of the form
#PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof