Use git_common to call git

In preparation for some Windows optimizations to how git_common calls
git it is important to use git_common more widely, specifically from
scm.py and gclient_scm.py. This change updates scm.py and gclient_scm.py
and updates the associated tests:

Test command lines used when updating the tests include:
vpython3 tests/gclient_scm_test.py ManagedGitWrapperTestCaseMock.testUpdateConflict

vpython3 tests/gclient_scm_test.py GerritChangesTest.testRecoversAfterPatchFailure

vpython3 tests/gerrit_util_test.py CookiesAuthenticatorTest.testGetGitcookiesPath

Bug: 332982922
Change-Id: I7aacb110b2888c164259815385cd77e26942adc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5478509
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
This commit is contained in:
Bruce Dawson
2024-05-23 06:14:38 +00:00
committed by LUCI CQ
parent 4071d0d728
commit 062ecac69f
4 changed files with 54 additions and 49 deletions

View File

@@ -22,6 +22,7 @@ import traceback
import gclient_utils
import gerrit_util
import git_cache
import git_common
import scm
import subprocess2
@@ -1578,8 +1579,8 @@ class GitWrapper(SCMWrapper):
env.setdefault(
'GIT_DIR',
os.path.abspath(os.path.join(self.checkout_path, '.git')))
ret = subprocess2.check_output(['git'] + args, env=env,
**kwargs).decode('utf-8')
kwargs.setdefault('env', env)
ret = git_common.run(*args, **kwargs)
if strip:
ret = ret.strip()
self.Print('Finished running: %s %s' % ('git', ' '.join(args)))