From e47ac15d93b88d76e38e56054a15dfb916b30112 Mon Sep 17 00:00:00 2001 From: Aiden Benner Date: Tue, 20 Nov 2018 16:44:03 +0000 Subject: [PATCH] Fix git cl format --python on windows git cl format --python currently breaks on windows because FindExecutable('yapf') returns .../depot_tools/yapf (a py file) instead of .../depot_tools/yapf.bat. Also yapf.bat tries to run the yapf py file without vpython which breaks the yapf dependency. This CL fixes these two issues. Bug:846432 Change-Id: I551a4c1e6367074fa76767851bd34feb2dcfb6a2 Reviewed-on: https://chromium-review.googlesource.com/c/1341236 Reviewed-by: Robbie Iannucci Commit-Queue: Aiden Benner --- git_cl.py | 8 ++++---- yapf.bat | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/git_cl.py b/git_cl.py index 4dd1cd3b5..ca1bcad24 100755 --- a/git_cl.py +++ b/git_cl.py @@ -5664,13 +5664,13 @@ def CMDformat(parser, args): # Similar code to above, but using yapf on .py files rather than clang-format # on C/C++ files if opts.python and python_diff_files: - yapf_tool = gclient_utils.FindExecutable('yapf') - if yapf_tool is None: - DieWithError('yapf not found in PATH') + depot_tools_path = os.path.dirname(os.path.abspath(__file__)) + yapf_tool = os.path.join(depot_tools_path, 'yapf') + if sys.platform.startswith('win'): + yapf_tool += '.bat' # If we couldn't find a yapf file we'll default to the chromium style # specified in depot_tools. - depot_tools_path = os.path.dirname(os.path.abspath(__file__)) chromium_default_yapf_style = os.path.join(depot_tools_path, YAPF_CONFIG_FILENAME) diff --git a/yapf.bat b/yapf.bat index 06390ffcf..088410977 100755 --- a/yapf.bat +++ b/yapf.bat @@ -9,4 +9,4 @@ setlocal set PATH=%PATH%;%~dp0 :: Defer control. -python "%~dp0\yapf" %* +vpython "%~dp0\yapf" %*