Skip to content

Commit 0aff69f

Browse files
[tool] Ignore GeneratedPluginRegistrant.swift for format (#6195)
This file fails `swift-format lint`, so including it in `format` causes lots of warnings when run locally.
1 parent f9171d1 commit 0aff69f

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

script/tool/lib/src/format_command.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ class FormatCommand extends PackageCommand {
346346
pathFragmentForDirectories(<String>['example', 'build'])) &&
347347
// Ignore files in Pods, which are not part of the repository.
348348
!path.contains(pathFragmentForDirectories(<String>['Pods'])) &&
349+
// See https://github.com/flutter/flutter/issues/144039
350+
!path.endsWith('GeneratedPluginRegistrant.swift') &&
349351
// Ignore .dart_tool/, which can have various intermediate files.
350352
!path.contains(pathFragmentForDirectories(<String>['.dart_tool'])))
351353
.toList();

script/tool/test/format_command_test.dart

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,52 @@ void main() {
737737
]));
738738
});
739739

740+
test('skips GeneratedPluginRegistrant.swift', () async {
741+
const String sourceFile = 'macos/Classes/Foo.swift';
742+
final RepositoryPackage plugin = createFakePlugin(
743+
'a_plugin',
744+
packagesDir,
745+
extraFiles: <String>[
746+
sourceFile,
747+
'example/macos/Flutter/GeneratedPluginRegistrant.swift',
748+
],
749+
);
750+
751+
await runCapturingPrint(runner, <String>[
752+
'format',
753+
'--swift',
754+
'--swift-format-path=/path/to/swift-format'
755+
]);
756+
757+
expect(
758+
processRunner.recordedCalls,
759+
orderedEquals(<ProcessCall>[
760+
const ProcessCall(
761+
'/path/to/swift-format',
762+
<String>['--version'],
763+
null,
764+
),
765+
ProcessCall(
766+
'/path/to/swift-format',
767+
<String>[
768+
'-i',
769+
...getPackagesDirRelativePaths(plugin, <String>[sourceFile])
770+
],
771+
packagesDir.path,
772+
),
773+
ProcessCall(
774+
'/path/to/swift-format',
775+
<String>[
776+
'lint',
777+
'--parallel',
778+
'--strict',
779+
...getPackagesDirRelativePaths(plugin, <String>[sourceFile]),
780+
],
781+
packagesDir.path,
782+
),
783+
]));
784+
});
785+
740786
test('fails if files are changed with --fail-on-change', () async {
741787
const List<String> files = <String>[
742788
'linux/foo_plugin.cc',

0 commit comments

Comments
 (0)