Add timeout to git call in windows toolchain update script

VSCode will intercept git calls from its embedded terminal under at
least some circumstances. If this happens, it will create a small,
easily-missable dialogue box, causing the script to hang until the
box is closed. As a far as I can tell, there's no way to prevent
VSCode from doing this.

To prevent this from happening during windows toolchain updates,
we add a timeout to the relevant git call, which is checking for
certain permissions. If we don't get a quick response, we'll just
assume the permissions don't exist.

The call in question is one of three redundant checks, and returning
false is the conservative option, so this shouldn't cause any problems.
The only minor annoyance is that this leaves the dialogue box at the
top of the VSCode UI until the user does something about it, but once
the script has continued the box is harmless.

Bug: 376067358
Change-Id: I1a20257c52c3569a03797705d7460feedee9a124
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5979117
Reviewed-by: danakj <danakj@chromium.org>
Commit-Queue: Devon Loehr <dloehr@google.com>
changes/17/5979117/2
Devon Loehr 7 months ago committed by LUCI CQ
parent 9bf2a2011a
commit a423469b61

@ -236,15 +236,24 @@ def HaveSrcInternalAccess():
# Credential Manager for Windows 1.12. See https://crbug.com/755694 and
# https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/482.
child_env = dict(os.environ, GCM_INTERACTIVE='NEVER')
return subprocess.call([
'git', '-c', 'core.askpass=true', 'remote', 'show',
'https://chrome-internal.googlesource.com/chrome/src-internal/'
],
shell=True,
stdin=nul,
stdout=nul,
stderr=nul,
env=child_env) == 0
# If this script is run from an embedded terminal in VSCode, VSCode may
# intercept the git call and show an easily-missable username/passsword
# prompt. To ensure we can run without user input, just return false if
# we don't get a response quickly. See crbug.com/376067358.
try:
return subprocess.call(
[
'git', '-c', 'core.askpass=true', 'remote', 'show',
'https://chrome-internal.googlesource.com/chrome/src-internal/'
],
shell=True,
stdin=nul,
stdout=nul,
stderr=nul,
timeout=10, # seconds
env=child_env) == 0
except subprocess.TimeoutExpired:
return False
def LooksLikeGoogler():

Loading…
Cancel
Save