[flutter_plugin_tools] Add a federated PR safety check (#4329)

Creates a new command to validate that PRs don't change platform interface packages and implementations at the same time, to try to prevent ecosystem-breaking changes. See https://github.com/flutter/flutter/issues/89518 for context.

Per the explanation in the issue, this has carve-outs for:
- Changes to platform interfaces that aren't published (allowing for past uses cases such as making a substantive change to an implementation, and making minor adjustments to comments in the PI package based on those changes).
- Things that look like bulk changes (e.g., a mass change to account for a new lint rule)

Fixes https://github.com/flutter/flutter/issues/89518
This commit is contained in:
stuartmorgan
2021-09-20 13:54:02 -04:00
committed by GitHub
parent 927e0ab197
commit 1b95825c76
7 changed files with 518 additions and 8 deletions

View File

@ -210,17 +210,11 @@ class PubspecCheckCommand extends PackageLoopingCommand {
// Returns true if [packageName] appears to be an implementation package
// according to repository conventions.
bool _isImplementationPackage(RepositoryPackage package) {
// An implementation package should be in a group folder...
final Directory parentDir = package.directory.parent;
if (parentDir.path == packagesDir.path) {
if (!package.isFederated) {
return false;
}
final String packageName = package.directory.basename;
final String parentName = parentDir.basename;
// ... whose name is a prefix of the package name.
if (!packageName.startsWith(parentName)) {
return false;
}
final String parentName = package.directory.parent.basename;
// A few known package names are not implementation packages; assume
// anything else is. (This is done instead of listing known implementation
// suffixes to allow for non-standard suffixes; e.g., to put several