mirror of
https://github.com/flutter/packages.git
synced 2025-06-05 02:52:06 +08:00
[flutter_plugin_tools] Add 'main' support (#4474)
Treat `main` the same as `master` for branch-based switching, in preparation for switching the branch names in Flutter repositories. Also updates all of the tests that used `master` as the explicit base to use `main` instead; what the tests use is arbitrary, so they can be switched now even though the repo itself hasn't switched. Part of https://github.com/flutter/flutter/issues/90476
This commit is contained in:
@ -81,7 +81,8 @@ abstract class PluginCommand extends Command<void> {
|
||||
argParser.addFlag(_packagesForBranchArg,
|
||||
help:
|
||||
'This runs on all packages (equivalent to no package selection flag)\n'
|
||||
'on master, and behaves like --run-on-changed-packages on any other branch.\n\n'
|
||||
'on main (or master), and behaves like --run-on-changed-packages on '
|
||||
'any other branch.\n\n'
|
||||
'Cannot be combined with $_packagesArg.\n\n'
|
||||
'This is intended for use in CI.\n',
|
||||
hide: true);
|
||||
@ -301,7 +302,7 @@ abstract class PluginCommand extends Command<void> {
|
||||
'only be used in a git repository.');
|
||||
throw ToolExit(exitInvalidArguments);
|
||||
} else {
|
||||
runOnChangedPackages = branch != 'master';
|
||||
runOnChangedPackages = branch != 'master' && branch != 'main';
|
||||
// Log the mode for auditing what was intended to run.
|
||||
print('--$_packagesForBranchArg: running on '
|
||||
'${runOnChangedPackages ? 'changed' : 'all'} packages');
|
||||
|
@ -24,7 +24,7 @@ class TestCommand extends PackageLoopingCommand {
|
||||
defaultsTo: '',
|
||||
help:
|
||||
'Runs Dart unit tests in Dart VM with the given experiments enabled. '
|
||||
'See https://github.com/dart-lang/sdk/blob/master/docs/process/experimental-flags.md '
|
||||
'See https://github.com/dart-lang/sdk/blob/main/docs/process/experimental-flags.md '
|
||||
'for details.',
|
||||
);
|
||||
}
|
||||
|
@ -262,7 +262,9 @@ ${indentation}HTTP response: ${pubVersionFinderResponse.httpResponse.body}
|
||||
// This method isn't called unless `version` is non-null.
|
||||
final Version currentVersion = pubspec.version!;
|
||||
Version? previousVersion;
|
||||
String previousVersionSource;
|
||||
if (getBoolArg(_againstPubFlag)) {
|
||||
previousVersionSource = 'pub';
|
||||
previousVersion = await _fetchPreviousVersionFromPub(pubspec.name);
|
||||
if (previousVersion == null) {
|
||||
return _CurrentVersionState.unknown;
|
||||
@ -273,6 +275,7 @@ ${indentation}HTTP response: ${pubVersionFinderResponse.httpResponse.body}
|
||||
}
|
||||
} else {
|
||||
final GitVersionFinder gitVersionFinder = await retrieveVersionFinder();
|
||||
previousVersionSource = await gitVersionFinder.getBaseSha();
|
||||
previousVersion = await _getPreviousVersionFromGit(package,
|
||||
gitVersionFinder: gitVersionFinder) ??
|
||||
Version.none;
|
||||
@ -310,9 +313,8 @@ ${indentation}HTTP response: ${pubVersionFinderResponse.httpResponse.body}
|
||||
if (allowedNextVersions.containsKey(currentVersion)) {
|
||||
print('$indentation$previousVersion -> $currentVersion');
|
||||
} else {
|
||||
final String source = (getBoolArg(_againstPubFlag)) ? 'pub' : 'master';
|
||||
printError('${indentation}Incorrectly updated version.\n'
|
||||
'${indentation}HEAD: $currentVersion, $source: $previousVersion.\n'
|
||||
'${indentation}HEAD: $currentVersion, $previousVersionSource: $previousVersion.\n'
|
||||
'${indentation}Allowed versions: $allowedNextVersions');
|
||||
return _CurrentVersionState.invalidChange;
|
||||
}
|
||||
|
Reference in New Issue
Block a user