Don't be conservative in upgrade --major-versions without specific pa… (#3539)
diff --git a/lib/src/command/upgrade.dart b/lib/src/command/upgrade.dart index 25feb70..a83d129 100644 --- a/lib/src/command/upgrade.dart +++ b/lib/src/command/upgrade.dart
@@ -222,6 +222,14 @@ } final newPubspecText = _updatePubspec(changes); + // When doing '--majorVersions' for specific packages we try to update other + // packages as little as possible to make a focused change (SolveType.get). + // + // But without a specific package we want to get as many non-major updates + // as possible (SolveType.upgrade). + final solveType = + argResults.rest.isEmpty ? SolveType.upgrade : SolveType.get; + if (_dryRun) { // Even if it is a dry run, run `acquireDependencies` so that the user // gets a report on changes. @@ -233,7 +241,7 @@ lockFile: entrypoint.lockFile, solveResult: solveResult, ).acquireDependencies( - SolveType.get, + solveType, dryRun: true, precompile: _precompile, analytics: null, // No analytics for dry-run @@ -246,7 +254,7 @@ // we can show the changes when not in --dry-run mode. For now we only show // the changes made to pubspec.yaml in dry-run mode. await Entrypoint(directory, cache).acquireDependencies( - SolveType.get, + solveType, precompile: _precompile, analytics: analytics, );
diff --git a/test/testdata/goldens/upgrade/example_warns_about_major_versions_test/pub upgrade --major-versions does not update major versions in example~.txt b/test/testdata/goldens/upgrade/example_warns_about_major_versions_test/pub upgrade --major-versions does not update major versions in example~.txt index ae304ea..2cc96c0 100644 --- a/test/testdata/goldens/upgrade/example_warns_about_major_versions_test/pub upgrade --major-versions does not update major versions in example~.txt +++ b/test/testdata/goldens/upgrade/example_warns_about_major_versions_test/pub upgrade --major-versions does not update major versions in example~.txt
@@ -17,7 +17,9 @@ ## Section 1 $ pub upgrade --major-versions --directory example Resolving dependencies in example... + bar 2.0.0 > foo 2.0.0 (was 1.0.0) + myapp 0.0.0 from path . Changed 1 dependency in example! Changed 1 constraint in pubspec.yaml: