Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(790)

Unified Diff: git_cl.py

Issue 1074673002: Add OAuth2 support for end users (i.e. 3-legged flow with the browser). (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: windows lineendings for depot-tools-auth.bat Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « depot-tools-auth.py ('k') | oauth2.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl.py
diff --git a/git_cl.py b/git_cl.py
index 5484713c57cbc601481b388ee6a7380e87952923..d4486e5b10abd24e0667f0b6509695950029660d 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -2062,6 +2062,15 @@ def CMDupload(parser, args):
base_branch = cl.GetCommonAncestorWithUpstream()
args = [base_branch, 'HEAD']
+ # Make sure authenticated to Rietveld before running expensive hooks. It is
+ # a fast, best efforts check. Rietveld still can reject the authentication
+ # during the actual upload.
+ if not settings.GetIsGerrit() and auth_config.use_oauth2:
+ authenticator = auth.get_authenticator_for_host(
+ cl.GetRietveldServer(), auth_config)
+ if not authenticator.has_cached_credentials():
+ raise auth.LoginRequiredError(cl.GetRietveldServer())
+
# Apply watchlists on upload.
change = cl.GetChange(base_branch, None)
watchlist = watchlists.Watchlists(change.RepositoryRoot())
@@ -3179,6 +3188,8 @@ def main(argv):
dispatcher = subcommand.CommandDispatcher(__name__)
try:
return dispatcher.execute(OptionParser(), argv)
+ except auth.AuthenticationError as e:
+ DieWithError(str(e))
except urllib2.HTTPError, e:
if e.code != 500:
raise
« no previous file with comments | « depot-tools-auth.py ('k') | oauth2.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698