mirror of
https://github.com/flutter/packages.git
synced 2025-06-10 06:44:40 +08:00
Allow reverts when checking versions (#3981)
If a new version is lower than the current checked-in version, and the transition from the new version to the old version is valid (indicating that it could have been the previous version), allow the change. This prevents the version check from failing when reverting a PR. This is not fool-proof (e.g., it would allow a revert of an already-published PR); if we have issues in practice we can further restrict the check (by checking that the new version is the current pub version, for instance).
This commit is contained in:
@ -179,6 +179,20 @@ ${indentation}HTTP response: ${pubVersionFinderResponse.httpResponse.body}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check for reverts when doing local validation.
|
||||
if (!getBoolArg(_againstPubFlag) && headVersion < sourceVersion) {
|
||||
final Map<Version, NextVersionType> possibleVersionsFromNewVersion =
|
||||
getAllowedNextVersions(headVersion, sourceVersion);
|
||||
// Since this skips validation, try to ensure that it really is likely
|
||||
// to be a revert rather than a typo by checking that the transition
|
||||
// from the lower version to the new version would have been valid.
|
||||
if (possibleVersionsFromNewVersion.containsKey(sourceVersion)) {
|
||||
print('${indentation}New version is lower than previous version. '
|
||||
'This is assumed to be a revert.');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
final Map<Version, NextVersionType> allowedNextVersions =
|
||||
getAllowedNextVersions(sourceVersion, headVersion);
|
||||
|
||||
|
Reference in New Issue
Block a user