-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[flutter_tools] Upgrade only from flutter update-packages #103924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The || is extra it falls under the last else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, then the || is fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Jasguerrero
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the nit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.