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

13
scm.py
View File

@@ -10,6 +10,7 @@ import re
from typing import Mapping, List
import gclient_utils
import git_common
import subprocess2
# TODO: Should fix these warnings.
@@ -105,14 +106,10 @@ class GIT(object):
@staticmethod
def Capture(args, cwd=None, strip_out=True, **kwargs):
env = GIT.ApplyEnvVars(kwargs)
output = subprocess2.check_output(['git'] + args,
cwd=cwd,
stderr=subprocess2.PIPE,
env=env,
**kwargs)
output = output.decode('utf-8', 'replace')
return output.strip() if strip_out else output
kwargs.setdefault('env', GIT.ApplyEnvVars(kwargs))
kwargs.setdefault('cwd', cwd)
kwargs.setdefault('autostrip', strip_out)
return git_common.run(*args, **kwargs)
@staticmethod
def CaptureStatus(cwd,