From 7f39e3d1858ab69672cc9058313d9babf32226c3 Mon Sep 17 00:00:00 2001 From: Olivier Robin Date: Thu, 28 Apr 2022 08:20:49 +0000 Subject: [PATCH] Make swift-format default True on Mac hosts Also make swift lint strict to catch every formatting errors. Bug: 1263872 Change-Id: Ie717c1f03ec1a0257cafceecc2055767d0be2077 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3605589 Reviewed-by: Brian Ryner Auto-Submit: Olivier Robin Commit-Queue: Olivier Robin Reviewed-by: Gavin Mak --- git_cl.py | 4 ++-- swift_format.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/git_cl.py b/git_cl.py index 627f03e93..054f65905 100755 --- a/git_cl.py +++ b/git_cl.py @@ -5168,7 +5168,7 @@ def _RunSwiftFormat(opts, swift_diff_files, top_dir, upstream_commit): cmd = [swift_format_tool] if opts.dry_run: - cmd.append('lint') + cmd += ['lint', '-s'] else: cmd += ['format', '-i'] cmd += swift_diff_files @@ -5242,7 +5242,7 @@ def CMDformat(parser, args): '--swift-format', dest='use_swift_format', action='store_true', - default=False, + default=swift_format.IsSwiftFormatSupported(), help='Enables formatting of Swift file types using swift-format ' '(macOS host only).') parser.add_option( diff --git a/swift_format.py b/swift_format.py index 50536fe5e..219211da7 100644 --- a/swift_format.py +++ b/swift_format.py @@ -40,6 +40,8 @@ def FindSwiftFormatToolInChromiumTree(): def IsSwiftFormatSupported(): + if sys.platform != 'darwin': + return False try: FindSwiftFormatToolInChromiumTree() return True