[tools] fix version check command not working for new packages (#3818)

This commit is contained in:
Chris Yang
2021-04-21 16:40:20 -07:00
committed by GitHub
parent 63d42fcdb9
commit c4170d8f64
2 changed files with 21 additions and 1 deletions

View File

@ -3,7 +3,6 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:io' as io;
import 'package:meta/meta.dart';
import 'package:file/file.dart';
@ -121,6 +120,7 @@ class VersionCheckCommand extends PluginCommand {
if (masterVersion == null) {
print('${indentation}Unable to find pubspec in master. '
'Safe to ignore if the project is new.');
continue;
}
if (masterVersion == headVersion) {

View File

@ -61,6 +61,9 @@ void main() {
} else if (invocation.positionalArguments[0][0] == 'show') {
final String response =
gitShowResponses[invocation.positionalArguments[0][1]];
if (response == null) {
throw const io.ProcessException('git', <String>['show']);
}
when<String>(mockProcessResult.stdout as String).thenReturn(response);
} else if (invocation.positionalArguments[0][0] == 'merge-base') {
when<String>(mockProcessResult.stdout as String).thenReturn('abc123');
@ -150,6 +153,23 @@ void main() {
);
});
test('allows valid version for new package.', () async {
createFakePlugin('plugin', includeChangeLog: true, includeVersion: true);
gitDiffResponse = 'packages/plugin/pubspec.yaml';
gitShowResponses = <String, String>{
'HEAD:packages/plugin/pubspec.yaml': 'version: 1.0.0',
};
final List<String> output =
await runCapturingPrint(runner, <String>['version-check']);
expect(
output,
containsAllInOrder(<String>[
'No version check errors found!',
]),
);
});
test('denies invalid version without explicit base-sha', () async {
createFakePlugin('plugin', includeChangeLog: true, includeVersion: true);
gitDiffResponse = 'packages/plugin/pubspec.yaml';