Fix google-java-format exec when cipd package is not available.

Bug: 458101569
Change-Id: Ifcda7d8bf044c4867e2b49a1d9d7b895b43128d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7130803
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
This commit is contained in:
Aleksei Khoroshilov
2025-11-07 10:21:25 -08:00
committed by LUCI CQ
parent ba27c7d48d
commit c81622f6bf

View File

@@ -25,16 +25,17 @@ def FindGoogleJavaFormat():
# Make relative to solution root if not an absolute path. # Make relative to solution root if not an absolute path.
return os.path.join(primary_solution_path, override) return os.path.join(primary_solution_path, override)
bin_dir = os.path.join(primary_solution_path, 'third_party', bin_path = os.path.join(primary_solution_path, 'third_party',
'google-java-format') 'google-java-format', 'google-java-format')
bin_path = os.path.join(bin_dir, '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 # Check that the .jar exists, since it is conditionally downloaded via
# DEPS conditions. # DEPS conditions.
if os.path.exists(bin_path): if os.path.exists(bin_path) and (os.path.exists(bin_path + '.jar')
if glob.glob(os.path.join(bin_dir, '*.jar')) or glob.glob( or os.path.exists(cipd_path)):
os.path.join(bin_dir, 'cipd', '*.jar')): return bin_path
return bin_path
return None return None