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

Unified Diff: scm.py

Issue 247493002: Eliminate all interactive terminal prompts from git. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: fix scm_unittest.py Created 6 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 | « gclient_scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scm.py
diff --git a/scm.py b/scm.py
index 4703e61b3051fd1a90faaf3aa100b59cb448428d..eb5c52403c3e2595d14b133a7d0d00e289811d10 100644
--- a/scm.py
+++ b/scm.py
@@ -97,10 +97,25 @@ class GIT(object):
current_version = None
@staticmethod
- def Capture(args, cwd, strip_out=True, **kwargs):
- env = os.environ.copy()
+ def ApplyEnvVars(kwargs):
+ env = kwargs.pop('env', None) or os.environ.copy()
+ # Don't prompt for passwords; just fail quickly and noisily.
+ # By default, git will use an interactive terminal prompt when a username/
+ # password is needed. That shouldn't happen in the chromium workflow,
+ # and if it does, then gclient may hide the prompt in the midst of a flood
+ # of terminal spew. The only indication that something has gone wrong
+ # will be when gclient hangs unresponsively. Instead, we disable the
+ # password prompt and simply allow git to fail noisily. The error
+ # message produced by git will be copied to gclient's output.
+ env.setdefault('GIT_ASKPASS', 'true')
+ env.setdefault('SSH_ASKPASS', 'true')
# 'cat' is a magical git string that disables pagers on all platforms.
- env['GIT_PAGER'] = 'cat'
+ env.setdefault('GIT_PAGER', 'cat')
+ return env
+
+ @staticmethod
+ def Capture(args, cwd, strip_out=True, **kwargs):
+ env = GIT.ApplyEnvVars(kwargs)
output = subprocess2.check_output(
['git'] + args,
cwd=cwd, stderr=subprocess2.PIPE, env=env, **kwargs)
« no previous file with comments | « gclient_scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698