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>
diff --git a/git_cl.py b/git_cl.py
index 4dd1cd3..ca1bcad 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -5664,13 +5664,13 @@
# 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)