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

[flutter_plugin_tools] Allow overriding breaking change check #4369

Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 12 additions & 2 deletions script/tool/lib/src/version_check_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import 'common/process_runner.dart';
import 'common/pub_version_finder.dart';
import 'common/repository_package.dart';

const int _exitMissingChangeDescriptionFile = 3;

/// Categories of version change types.
enum NextVersionType {
/// A breaking change.
Expand Down Expand Up @@ -319,7 +321,10 @@ ${indentation}HTTP response: ${pubVersionFinderResponse.httpResponse.body}
!_validateBreakingChange(package)) {
printError('${indentation}Breaking change detected.\n'
'${indentation}Breaking changes to platform interfaces are not '
'allowed without explicit justification.\n');
'allowed without explicit justification.\n'
'${indentation}See '
'https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages '
'for more information.');
return _CurrentVersionState.invalidChange;
}

Expand Down Expand Up @@ -453,6 +458,11 @@ ${indentation}The first version listed in CHANGELOG.md is $fromChangeLog.
if (path.isEmpty) {
return '';
}
return packagesDir.fileSystem.file(path).readAsStringSync();
final File file = packagesDir.fileSystem.file(path);
if (!file.existsSync()) {
printError('${indentation}No such file: $path');
throw ToolExit(_exitMissingChangeDescriptionFile);
Copy link
Member

@ditman ditman Sep 23, 2021

Choose a reason for hiding this comment

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

Yeah, since this file (and its path) are managed by the cirrus.yaml, it makes more sense that this is a tool exit error, good call! 🚀

}
return file.readAsStringSync();
}
}
27 changes: 27 additions & 0 deletions script/tool/test/version_check_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,33 @@ This is necessary because of X, Y, and Z
);
});

test('throws if a nonexistent change description file is specified',
() async {
createFakePlugin('plugin_platform_interface', packagesDir,
version: '2.0.0');
gitShowResponses = <String, String>{
'master:packages/plugin_platform_interface/pubspec.yaml':
'version: 1.0.0',
};

Error? commandError;
final List<String> output = await runCapturingPrint(runner, <String>[
'version-check',
'--base-sha=master',
'--change-description-file=a_missing_file.txt'
], errorHandler: (Error e) {
commandError = e;
});

expect(commandError, isA<ToolExit>());
expect(
output,
containsAllInOrder(<Matcher>[
contains('No such file: a_missing_file.txt'),
]),
);
});

test('allows breaking changes to platform interfaces with bypass flag',
() async {
createFakePlugin('plugin_platform_interface', packagesDir,
Expand Down