mirror of
https://github.com/flutter/packages.git
synced 2025-05-31 13:38:45 +08:00
[tools] fix version check command not working for new packages (#3818)
This commit is contained in:
@ -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) {
|
||||
|
@ -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';
|
||||
|
Reference in New Issue
Block a user