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 <iannucci@chromium.org>
Commit-Queue: Aiden Benner <abenner@google.com>
changes/36/1341236/4
Aiden Benner 7 years ago committed by Commit Bot
parent 7da982abf9
commit e47ac15d93

@ -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)

@ -9,4 +9,4 @@ setlocal
set PATH=%PATH%;%~dp0
:: Defer control.
python "%~dp0\yapf" %*
vpython "%~dp0\yapf" %*

Loading…
Cancel
Save