Skip to content

Commit 6abef22

Browse files
authored
[tool] Update .gitignore templates to include .flutter-plugins files (flutter#152950)
Fixes flutter#152793
1 parent b9ae1f1 commit 6abef22

File tree

4 files changed

+61
-19
lines changed

4 files changed

+61
-19
lines changed

packages/flutter_tools/templates/package/.gitignore.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ migrate_working_dir/
2626
/pubspec.lock
2727
**/doc/api/
2828
.dart_tool/
29+
.flutter-plugins
30+
.flutter-plugins-dependencies
2931
build/

packages/flutter_tools/templates/package_ffi/.gitignore.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ migrate_working_dir/
2626
/pubspec.lock
2727
**/doc/api/
2828
.dart_tool/
29+
.flutter-plugins
30+
.flutter-plugins-dependencies
2931
.packages
3032
build/

packages/flutter_tools/templates/plugin_shared/.gitignore.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ migrate_working_dir/
2828
/pubspec.lock
2929
**/doc/api/
3030
.dart_tool/
31+
.flutter-plugins
32+
.flutter-plugins-dependencies
3133
build/

packages/flutter_tools/test/commands.shard/permeable/create_test.dart

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ const String samplesIndexJson = '''
6666
{ "id": "sample2" }
6767
]''';
6868

69+
/// These files are generated for all project types.
70+
const List<String> flutterPluginsIgnores = <String>[
71+
'.flutter-plugins',
72+
'.flutter-plugins-dependencies',
73+
];
74+
6975
void main() {
7076
late Directory tempDir;
7177
late Directory projectDir;
@@ -177,6 +183,7 @@ void main() {
177183
'ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png',
178184
'lib/main.dart',
179185
],
186+
expectedGitignoreLines: flutterPluginsIgnores,
180187
);
181188
expect(logger.statusText, contains('In order to run your application, type:'));
182189
// Check that we're telling them about documentation
@@ -246,6 +253,7 @@ void main() {
246253
'pubspec.yaml',
247254
'README.md',
248255
],
256+
expectedGitignoreLines: flutterPluginsIgnores,
249257
);
250258
return _runFlutterTest(projectDir);
251259
}, overrides: <Type, Generator>{
@@ -288,22 +296,28 @@ void main() {
288296
});
289297

290298
testUsingContext('creates a module project correctly', () async {
291-
await _createAndAnalyzeProject(projectDir, <String>[
292-
'--template=module',
293-
], <String>[
294-
'.android/app/',
295-
'.gitignore',
296-
'.ios/Flutter',
297-
'.metadata',
298-
'analysis_options.yaml',
299-
'lib/main.dart',
300-
'pubspec.yaml',
301-
'README.md',
302-
'test/widget_test.dart',
303-
], unexpectedPaths: <String>[
304-
'android/',
305-
'ios/',
306-
]);
299+
await _createAndAnalyzeProject(
300+
projectDir,
301+
<String>[
302+
'--template=module',
303+
],
304+
<String>[
305+
'.android/app/',
306+
'.gitignore',
307+
'.ios/Flutter',
308+
'.metadata',
309+
'analysis_options.yaml',
310+
'lib/main.dart',
311+
'pubspec.yaml',
312+
'README.md',
313+
'test/widget_test.dart',
314+
],
315+
unexpectedPaths: <String>[
316+
'android/',
317+
'ios/',
318+
],
319+
expectedGitignoreLines: flutterPluginsIgnores,
320+
);
307321
return _runFlutterTest(projectDir);
308322
}, overrides: <Type, Generator>{
309323
Pub: () => Pub.test(
@@ -568,6 +582,7 @@ void main() {
568582
'linux/flutter/generated_plugins.cmake',
569583
'macos/Flutter/GeneratedPluginRegistrant.swift',
570584
],
585+
expectedGitignoreLines: flutterPluginsIgnores,
571586
);
572587
return _runFlutterTest(projectDir);
573588
}, overrides: <Type, Generator>{
@@ -599,6 +614,7 @@ void main() {
599614
'example/android/app/src/main/java/com/example/flutter_project_example/MainActivity.java',
600615
'lib/flutter_project_web.dart',
601616
],
617+
expectedGitignoreLines: flutterPluginsIgnores,
602618
);
603619
return _runFlutterTest(projectDir.childDirectory('example'));
604620
}, overrides: <Type, Generator>{
@@ -2148,6 +2164,7 @@ void main() {
21482164
'ios/Flutter/AppFrameworkInfo.plist',
21492165
],
21502166
unexpectedPaths: <String>['test'],
2167+
expectedGitignoreLines: flutterPluginsIgnores,
21512168
);
21522169
expect(projectDir.childDirectory('lib').childFile('main.dart').readAsStringSync(),
21532170
contains("Text('Hello World!')"));
@@ -2236,6 +2253,7 @@ void main() {
22362253
'ios/Flutter/AppFrameworkInfo.plist',
22372254
],
22382255
unexpectedPaths: <String>['test'],
2256+
expectedGitignoreLines: flutterPluginsIgnores,
22392257
);
22402258
expect(projectDir.childDirectory('lib').childFile('main.dart').readAsStringSync(),
22412259
contains('void main() {}'));
@@ -3915,6 +3933,7 @@ Future<void> _createProject(
39153933
List<String> createArgs,
39163934
List<String> expectedPaths, {
39173935
List<String> unexpectedPaths = const <String>[],
3936+
List<String> expectedGitignoreLines = const <String>[],
39183937
}) async {
39193938
Cache.flutterRoot = '../..';
39203939
final CreateCommand command = CreateCommand();
@@ -3930,24 +3949,41 @@ Future<void> _createProject(
39303949
return globals.fs.typeSync(fullPath) != FileSystemEntityType.notFound;
39313950
}
39323951

3933-
final List<String> failures = <String>[
3952+
final List<String> pathFailures = <String>[
39343953
for (final String path in expectedPaths)
39353954
if (!pathExists(path))
39363955
'Path "$path" does not exist.',
39373956
for (final String path in unexpectedPaths)
39383957
if (pathExists(path))
39393958
'Path "$path" exists when it shouldn\'t.',
39403959
];
3941-
expect(failures, isEmpty, reason: failures.join('\n'));
3960+
expect(pathFailures, isEmpty, reason: pathFailures.join('\n'));
3961+
3962+
final String gitignorePath = globals.fs.path.join(dir.path, '.gitignore');
3963+
final List<String> gitignore = globals.fs.file(gitignorePath).readAsLinesSync();
3964+
3965+
final List<String> gitignoreFailures = <String>[
3966+
for (final String line in expectedGitignoreLines)
3967+
if (!gitignore.contains(line))
3968+
'Expected .gitignore to contain "$line".',
3969+
];
3970+
expect(gitignoreFailures, isEmpty, reason: gitignoreFailures.join('\n'));
39423971
}
39433972

39443973
Future<void> _createAndAnalyzeProject(
39453974
Directory dir,
39463975
List<String> createArgs,
39473976
List<String> expectedPaths, {
39483977
List<String> unexpectedPaths = const <String>[],
3978+
List<String> expectedGitignoreLines = const <String>[],
39493979
}) async {
3950-
await _createProject(dir, createArgs, expectedPaths, unexpectedPaths: unexpectedPaths);
3980+
await _createProject(
3981+
dir,
3982+
createArgs,
3983+
expectedPaths,
3984+
unexpectedPaths: unexpectedPaths,
3985+
expectedGitignoreLines: expectedGitignoreLines,
3986+
);
39513987
await _analyzeProject(dir.path);
39523988
}
39533989

0 commit comments

Comments
 (0)