[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/506374
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Daniel Jacques <dnj@chromium.org>
changes/74/506374/2
Dan Jacques 8 years ago committed by Commit Bot
parent 71c661ecd9
commit e2af38e019

@ -122,7 +122,15 @@ def main(args):
# If we're using the Infra Git wrapper, do nothing here.
# https://chromium.googlesource.com/infra/infra/+/master/go/src/infra/tools/git
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.disable_interspersed_args()

Loading…
Cancel
Save