[flutter_plugin_tools] ignore flutter_plugin_tools when publishing (#4110)

This commit is contained in:
Chris Yang
2021-06-28 09:06:03 -07:00
committed by GitHub
parent fef8e6c2fb
commit 355ffc0a88
2 changed files with 59 additions and 0 deletions

View File

@ -290,6 +290,14 @@ Safe to ignore if the package is deleted in this commit.
}
final Pubspec pubspec = Pubspec.parse(pubspecFile.readAsStringSync());
if (pubspec.name == 'flutter_plugin_tools') {
// Ignore flutter_plugin_tools package when running publishing through flutter_plugin_tools.
// TODO(cyanglaz): Make the tool also auto publish flutter_plugin_tools package.
// https://github.com/flutter/flutter/issues/85430
return _CheckNeedsReleaseResult.noRelease;
}
if (pubspec.publishTo == 'none') {
return _CheckNeedsReleaseResult.noRelease;
}

View File

@ -995,6 +995,57 @@ void main() {
]));
expect(processRunner.pushTagsArgs, isEmpty);
});
test('Do not release flutter_plugin_tools', () async {
const Map<String, dynamic> httpResponsePlugin1 = <String, dynamic>{
'name': 'flutter_plugin_tools',
'versions': <String>[],
};
final MockClient mockClient = MockClient((http.Request request) async {
if (request.url.pathSegments.last == 'flutter_plugin_tools.json') {
return http.Response(json.encode(httpResponsePlugin1), 200);
}
return http.Response('', 500);
});
final PublishPluginCommand command = PublishPluginCommand(packagesDir,
processRunner: processRunner,
print: (Object? message) => printedMessages.add(message.toString()),
stdinput: mockStdin,
httpClient: mockClient,
gitDir: gitDir);
commandRunner = CommandRunner<void>(
'publish_check_command',
'Test for publish-check command.',
);
commandRunner.addCommand(command);
final Directory flutterPluginTools =
createFakePlugin('flutter_plugin_tools', packagesDir);
await gitDir.runCommand(<String>['add', '-A']);
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
// Immediately return 0 when running `pub publish`.
processRunner.mockPublishCompleteCode = 0;
mockStdin.readLineOutput = 'y';
await commandRunner
.run(<String>['publish-plugin', '--all-changed', '--base-sha=HEAD~']);
expect(
printedMessages,
containsAllInOrder(<String>[
'Checking local repo...',
'Local repo is ready!',
'Done!'
]));
expect(
printedMessages.contains(
'Running `pub publish ` in ${flutterPluginTools.path}...\n',
),
isFalse);
expect(processRunner.pushTagsArgs, isEmpty);
processRunner.pushTagsArgs.clear();
printedMessages.clear();
});
});
}