Skip to content

Commit 81a9537

Browse files
author
Chris Yang
authored
[tools] fix version check command not working for new packages (flutter#3818)
1 parent 9ac4fb8 commit 81a9537

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

script/tool/lib/src/version_check_command.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// found in the LICENSE file.
44

55
import 'dart:async';
6-
import 'dart:io' as io;
76

87
import 'package:meta/meta.dart';
98
import 'package:file/file.dart';
@@ -121,6 +120,7 @@ class VersionCheckCommand extends PluginCommand {
121120
if (masterVersion == null) {
122121
print('${indentation}Unable to find pubspec in master. '
123122
'Safe to ignore if the project is new.');
123+
continue;
124124
}
125125

126126
if (masterVersion == headVersion) {

script/tool/test/version_check_test.dart

+20
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ void main() {
6161
} else if (invocation.positionalArguments[0][0] == 'show') {
6262
final String response =
6363
gitShowResponses[invocation.positionalArguments[0][1]];
64+
if (response == null) {
65+
throw const io.ProcessException('git', <String>['show']);
66+
}
6467
when<String>(mockProcessResult.stdout as String).thenReturn(response);
6568
} else if (invocation.positionalArguments[0][0] == 'merge-base') {
6669
when<String>(mockProcessResult.stdout as String).thenReturn('abc123');
@@ -150,6 +153,23 @@ void main() {
150153
);
151154
});
152155

156+
test('allows valid version for new package.', () async {
157+
createFakePlugin('plugin', includeChangeLog: true, includeVersion: true);
158+
gitDiffResponse = 'packages/plugin/pubspec.yaml';
159+
gitShowResponses = <String, String>{
160+
'HEAD:packages/plugin/pubspec.yaml': 'version: 1.0.0',
161+
};
162+
final List<String> output =
163+
await runCapturingPrint(runner, <String>['version-check']);
164+
165+
expect(
166+
output,
167+
containsAllInOrder(<String>[
168+
'No version check errors found!',
169+
]),
170+
);
171+
});
172+
153173
test('denies invalid version without explicit base-sha', () async {
154174
createFakePlugin('plugin', includeChangeLog: true, includeVersion: true);
155175
gitDiffResponse = 'packages/plugin/pubspec.yaml';

0 commit comments

Comments
 (0)