From 89624cdfd788eb9ea4e632f97ba43f522c57a1d2 Mon Sep 17 00:00:00 2001 From: Edward Lesmes Date: Mon, 6 Apr 2020 17:51:56 +0000 Subject: [PATCH] Reland "git-cl: Execute clang-format-diff.py using vpython." This is a reland of 87661afbfc1b59fbfb64183379f2aadaac6c84c7 Set shell=True on Windows, so that vpython.bat can be executed. Original change's description: > git-cl: Execute clang-format-diff.py using vpython. > > When running git-cl using vpython3, sys.executable is python3. > Execute clang-format-diff.py using vpython instead, since it has > not been migrated already. > > Bug: 1066187 > Change-Id: I31556acb50ff4256706a313c1393eddad9f903f3 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2130926 > Reviewed-by: Josip Sokcevic > Commit-Queue: Edward Lesmes Bug: 1066187 Change-Id: Ia482f13d0f30d625f2f6db3cb4202b7f3f95707b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2135330 Reviewed-by: Josip Sokcevic Commit-Queue: Edward Lesmes --- git_cl.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/git_cl.py b/git_cl.py index 30800918dc..c5c14249e8 100755 --- a/git_cl.py +++ b/git_cl.py @@ -4750,22 +4750,25 @@ def _RunClangFormatDiff(opts, clang_diff_files, top_dir, upstream_commit): if opts.diff: sys.stdout.write(stdout) else: - env = os.environ.copy() - env['PATH'] = str(os.path.dirname(clang_format_tool)) try: script = clang_format.FindClangFormatScriptInChromiumTree( 'clang-format-diff.py') except clang_format.NotFoundError as e: DieWithError(e) - cmd = [sys.executable, script, '-p0'] + cmd = ['vpython', script, '-p0'] if not opts.dry_run and not opts.diff: cmd.append('-i') diff_cmd = BuildGitDiffCmd('-U0', upstream_commit, clang_diff_files) diff_output = RunGit(diff_cmd).encode('utf-8') - stdout = RunCommand(cmd, stdin=diff_output, cwd=top_dir, env=env) + env = os.environ.copy() + env['PATH'] = ( + str(os.path.dirname(clang_format_tool)) + os.pathsep + env['PATH']) + stdout = RunCommand( + cmd, stdin=diff_output, cwd=top_dir, env=env, + shell=bool(sys.platform.startswith('win32'))) if opts.diff: sys.stdout.write(stdout) if opts.dry_run and len(stdout) > 0: @@ -4967,7 +4970,7 @@ def CMDformat(parser, args): cmd.append('--dry-run') for gn_diff_file in gn_diff_files: gn_ret = subprocess2.call(cmd + [gn_diff_file], - shell=sys.platform == 'win32', + shell=bool(sys.platform.startswith('win')), cwd=top_dir) if opts.dry_run and gn_ret == 2: return_value = 2 # Not formatted.