[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:
stuartmorgan
2021-11-10 14:46:35 -05:00
committed by GitHub
parent 78395e5adf
commit 5d15fe9626
9 changed files with 122 additions and 148 deletions

View File

@ -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;
}