git cl format: Enable google-java-format by default.
Removes --google-java-format and adds --no-java.
Does not provide a way to fallback to clang-format, since there is no
established way for projects to declare which formatters they prefer to
use.
Bug: 1462204
Change-Id: Ie116e73ccad0fbd55c968248ae2ebeca130a3f80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4905866
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 2fa2bd1..05ff2f5 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -6371,7 +6371,7 @@
@metrics.collector.collect_metrics('git cl format')
def CMDformat(parser, args):
"""Runs auto-formatting tools (clang-format etc.) on the diff."""
- clang_exts = ['.cc', '.cpp', '.h', '.m', '.mm', '.proto', '.java']
+ clang_exts = ['.cc', '.cpp', '.h', '.m', '.mm', '.proto']
GN_EXTS = ['.gn', '.gni', '.typemap']
parser.add_option('--full',
action='store_true',
@@ -6433,10 +6433,9 @@
action='store_false',
help='Disables formatting of Swift file types using swift-format.')
- # Temporary flag to test with google-java-format.
- parser.add_option('--google-java-format',
+ parser.add_option('--no-java',
action='store_true',
- help=optparse.SUPPRESS_HELP)
+ help='Disable auto-formatting of .java')
opts, args = parser.parse_args(args)
@@ -6480,8 +6479,7 @@
(GN_EXTS, _RunGnFormat),
(['.xml'], _FormatXml),
]
- if opts.google_java_format:
- clang_exts.remove('.java')
+ if not opts.no_java:
formatters += [(['.java'], _RunGoogleJavaFormat)]
if opts.clang_format:
formatters += [(clang_exts, _RunClangFormatDiff)]