Commit 08f4d59e authored by Johnny(Jianning) Ding's avatar Johnny(Jianning) Ding Committed by LUCI CQ

Decode the returned encoded bytes of subprocess.check_all/check_output.

Bug: 1068779
Change-Id: Ie399e134577732b441c37ca2083d72a66bb631c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2142745Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Johnny (Jianning) Ding <jnd@chromium.org>
parent b71a96f8
......@@ -320,7 +320,10 @@ class _Drover(object):
stderr = None if self._verbose else _DEV_NULL_FILE
try:
return run(['git'] + args, shell=False, cwd=cwd, stderr=stderr)
rv = run(['git'] + args, shell=False, cwd=cwd, stderr=stderr)
if sys.version_info.major == 3:
return rv.decode('utf-8', 'ignore')
return rv
except (OSError, subprocess.CalledProcessError) as e:
if error_message:
raise Error(error_message)
......
......@@ -121,13 +121,16 @@ class GitDroverTest(unittest.TestCase):
self._fail_on_command == len(self._commands)):
self._fail_on_command = None
raise subprocess.CalledProcessError(1, args[0])
rv = ''
if args == ['git', 'rev-parse', '--git-dir']:
return os.path.join(self._parent_repo, '.git')
rv = os.path.join(self._parent_repo, '.git')
if args == ['git', '-c', 'core.quotePath=false', 'status', '--porcelain']:
return ' D foo\nUU baz\n D bar\n'
rv = ' D foo\nUU baz\n D bar\n'
if args == ['git', 'log', '-1', '--format=%ae']:
return 'author@domain.org'
return ''
rv = 'author@domain.org'
if sys.version_info.major == 3:
return bytes(rv, 'utf-8')
return rv
def _Popen(self, args, shell=False, cwd=None, stdin=None, stdout=None,
stderr=None):
......
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