Commit e47ac15d authored by Aiden Benner's avatar Aiden Benner Committed by Commit Bot

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/1341236Reviewed-by: 's avatarRobbie Iannucci <iannucci@chromium.org>
Commit-Queue: Aiden Benner <abenner@google.com>
parent 7da982ab
......@@ -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" %*
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