[flutter_tools] Upgrade only from flutter update-packages#103924
[flutter_tools] Upgrade only from flutter update-packages#103924fluttergithubbot merged 6 commits intoflutter:masterfrom
Conversation
There was a problem hiding this comment.
The || is extra it falls under the last else
There was a problem hiding this comment.
I think if doUpgrade is true, and version = 'any', then without the ||, we could end up with versionToUse = '>= any'". Not sure if pub would like that.
There was a problem hiding this comment.
Right, then the || is fine
There was a problem hiding this comment.
I have a general question about private methods. Is it ok to make them public as long as you add the visibleForTesting? Quoting Dan in this answer "if it's something worth testing, it's something that's worth being public". Regardless of the answer this is a nit/curiosity
There was a problem hiding this comment.
I think it's a nice goal to strive for to only test public methods. However, this command would be incredibly difficult to end to end test. Also, this synthetic package gets created and deleted during the running of the command, so it would not really be practical to test after the command completed (the behavior we're interested in is also dependent on a heuristic algorithm inside the pub binary).
As for making this function public, I couldn't think of a reason we would ever need to call this function (other than in tests) in another library, and if we later do, we can always mark remove the annotation. The main drawback to using @visibleForTesting is that it is effectively public to any downstream users who don't gate their code on the analyzer, but we don't have to worry about that with the tool.
There was a problem hiding this comment.
I think if doUpgrade is true, and version = 'any', then without the ||, we could end up with versionToUse = '>= any'". Not sure if pub would like that.
packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart
Outdated
Show resolved
Hide resolved
f28eef8 to
900a69d
Compare
|
This pull request is not suitable for automatic merging in its current state.
|
Fixes #102781
Previously,
flutter update-packages --force-upgradecommand would:anypub geton the synthetic package, allowing pub to version solve and determine the "best" version solutionThe problem with this algorithm is that the "best version solution" algorithm from step 4 that
pub getuses is a heuristic that can sometimes result in certain packages getting downgraded relative to the previous run (see #102781 (comment) for more details).This PR solves the problem by substituting
>= $prevVersionforanyin step 3. This will precludepubfrom consideration a solution that would downgrade a package.