Skip to content

Commit 8af8001

Browse files
author
Chris Yang
authored
[flutter_plugin_tools] ignore flutter_plugin_tools when publishing (flutter#4110)
1 parent fde1471 commit 8af8001

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

script/tool/lib/src/publish_plugin_command.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,14 @@ Safe to ignore if the package is deleted in this commit.
290290
}
291291

292292
final Pubspec pubspec = Pubspec.parse(pubspecFile.readAsStringSync());
293+
294+
if (pubspec.name == 'flutter_plugin_tools') {
295+
// Ignore flutter_plugin_tools package when running publishing through flutter_plugin_tools.
296+
// TODO(cyanglaz): Make the tool also auto publish flutter_plugin_tools package.
297+
// https://github.com/flutter/flutter/issues/85430
298+
return _CheckNeedsReleaseResult.noRelease;
299+
}
300+
293301
if (pubspec.publishTo == 'none') {
294302
return _CheckNeedsReleaseResult.noRelease;
295303
}

script/tool/test/publish_plugin_command_test.dart

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,57 @@ void main() {
995995
]));
996996
expect(processRunner.pushTagsArgs, isEmpty);
997997
});
998+
999+
test('Do not release flutter_plugin_tools', () async {
1000+
const Map<String, dynamic> httpResponsePlugin1 = <String, dynamic>{
1001+
'name': 'flutter_plugin_tools',
1002+
'versions': <String>[],
1003+
};
1004+
1005+
final MockClient mockClient = MockClient((http.Request request) async {
1006+
if (request.url.pathSegments.last == 'flutter_plugin_tools.json') {
1007+
return http.Response(json.encode(httpResponsePlugin1), 200);
1008+
}
1009+
return http.Response('', 500);
1010+
});
1011+
final PublishPluginCommand command = PublishPluginCommand(packagesDir,
1012+
processRunner: processRunner,
1013+
print: (Object? message) => printedMessages.add(message.toString()),
1014+
stdinput: mockStdin,
1015+
httpClient: mockClient,
1016+
gitDir: gitDir);
1017+
1018+
commandRunner = CommandRunner<void>(
1019+
'publish_check_command',
1020+
'Test for publish-check command.',
1021+
);
1022+
commandRunner.addCommand(command);
1023+
1024+
final Directory flutterPluginTools =
1025+
createFakePlugin('flutter_plugin_tools', packagesDir);
1026+
await gitDir.runCommand(<String>['add', '-A']);
1027+
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
1028+
// Immediately return 0 when running `pub publish`.
1029+
processRunner.mockPublishCompleteCode = 0;
1030+
mockStdin.readLineOutput = 'y';
1031+
await commandRunner
1032+
.run(<String>['publish-plugin', '--all-changed', '--base-sha=HEAD~']);
1033+
expect(
1034+
printedMessages,
1035+
containsAllInOrder(<String>[
1036+
'Checking local repo...',
1037+
'Local repo is ready!',
1038+
'Done!'
1039+
]));
1040+
expect(
1041+
printedMessages.contains(
1042+
'Running `pub publish ` in ${flutterPluginTools.path}...\n',
1043+
),
1044+
isFalse);
1045+
expect(processRunner.pushTagsArgs, isEmpty);
1046+
processRunner.pushTagsArgs.clear();
1047+
printedMessages.clear();
1048+
});
9981049
});
9991050
}
10001051

0 commit comments

Comments
 (0)