diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index 14dc8fb28ef8..0b552e8bff4d 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -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) { diff --git a/script/tool/test/version_check_test.dart b/script/tool/test/version_check_test.dart index ed953e0b7fa4..04348310a2f6 100644 --- a/script/tool/test/version_check_test.dart +++ b/script/tool/test/version_check_test.dart @@ -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', ['show']); + } when(mockProcessResult.stdout as String).thenReturn(response); } else if (invocation.positionalArguments[0][0] == 'merge-base') { when(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 = { + 'HEAD:packages/plugin/pubspec.yaml': 'version: 1.0.0', + }; + final List output = + await runCapturingPrint(runner, ['version-check']); + + expect( + output, + containsAllInOrder([ + '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';