Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

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

Merged
merged 4 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion script/tool/lib/src/version_check_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops 😬

}

if (masterVersion == headVersion) {
Expand Down
20 changes: 20 additions & 0 deletions script/tool/test/version_check_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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';
Expand Down