From 705b8d2d8508cb7914a872cfb99a1bfeb2519798 Mon Sep 17 00:00:00 2001 From: Joanna Wang Date: Fri, 7 Jun 2024 18:20:28 +0000 Subject: [PATCH] Fix google-java-format/cipd exists check. Bug: b/345761161 Change-Id: I3e3e7d84d962530b02a345d14ad8c15f57a49838 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5606286 Auto-Submit: Joanna Wang Commit-Queue: Josip Sokcevic Reviewed-by: Josip Sokcevic --- google_java_format.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/google_java_format.py b/google_java_format.py index 99b77056c..9e54bed68 100755 --- a/google_java_format.py +++ b/google_java_format.py @@ -24,17 +24,19 @@ def FindGoogleJavaFormat(): # Make relative to solution root if not an absolute path. return os.path.join(primary_solution_path, override) - path = os.path.join(primary_solution_path, 'third_party', - 'google-java-format', 'google-java-format') + bin_path = os.path.join(primary_solution_path, 'third_party', + 'google-java-format', 'google-java-format') + cipd_path = os.path.join(primary_solution_path, 'third_party', + 'google-java-format', 'cipd', + 'google-java-format.jar') # Check that the .jar exists, since it is conditionally downloaded via # DEPS conditions. # TODO(b/345761161): Remove old os.path.exists(path + '.jar') check, # when third_party/google-java-format # -> third_party/google-java-format/cipd is fully rolled out. - if os.path.exists(path) and ( - os.path.exists(path + '.jar') - or os.path.exists(os.path.join(path, 'cipd') + '.jar')): - return path + if os.path.exists(bin_path) and (os.path.exists(bin_path + '.jar') + or os.path.exists(cipd_path)): + return bin_path return None