Commit e2af38e0 authored by Dan Jacques's avatar Dan Jacques Committed by Commit Bot

[git retry] Fix Git wrapper fallthrough.

Currently, when the Infra Git wrapper is installed in PATH and a user
calls "git retry", the "git_retry.py" script is supposed to ignore the
request and fall through to the underlying command, relying on the Git
wrapper to handle retries.

However, Git apparently prepends its own executable path to PATH when it
is called, preventing the Git wrapper from being invoked the second time
and removing retries altogether.

We circumvent this by removing Git's new PATH influence when falling
through.

BUG=chromium:721450
TEST=local
  - Ran locally before and after patch, confirmed that after
  successfully retries throgh the wrapper.

R=agable@chromium.org, iannucci@chromium.org

Change-Id: Iae3d7a8bf805a5ba2bf827b06006a990d94e96d9
Reviewed-on: https://chromium-review.googlesource.com/506374Reviewed-by: 's avatarRobbie Iannucci <iannucci@chromium.org>
Commit-Queue: Daniel Jacques <dnj@chromium.org>
parent 71c661ec
...@@ -122,7 +122,15 @@ def main(args): ...@@ -122,7 +122,15 @@ def main(args):
# If we're using the Infra Git wrapper, do nothing here. # If we're using the Infra Git wrapper, do nothing here.
# https://chromium.googlesource.com/infra/infra/+/master/go/src/infra/tools/git # https://chromium.googlesource.com/infra/infra/+/master/go/src/infra/tools/git
if 'INFRA_GIT_WRAPPER' in os.environ: if 'INFRA_GIT_WRAPPER' in os.environ:
return subprocess.call([GIT_EXE] + args) # Remove Git's execution path from PATH so that our call-through re-invokes
# the Git wrapper.
# See crbug.com/721450
env = os.environ.copy()
git_exec = subprocess.check_output([GIT_EXE, '--exec-path']).strip()
env['PATH'] = os.pathsep.join([
elem for elem in env.get('PATH', '').split(os.pathsep)
if elem != git_exec])
return subprocess.call([GIT_EXE] + args, env=env)
parser = optparse.OptionParser() parser = optparse.OptionParser()
parser.disable_interspersed_args() parser.disable_interspersed_args()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment