-
Notifications
You must be signed in to change notification settings - Fork 230
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
Add flag --unlock-transitive
to pub upgrade
#4403
Merged
sigurdm
merged 2 commits into
dart-lang:master
from
sigurdm:upgrade_unlock_transitive_deps
Oct 7, 2024
+164
−13
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -10,6 +10,7 @@ Usage: pub upgrade [dependencies...] | |||||
-n, --dry-run Report what dependencies would change but don't change any. | ||||||
--[no-]precompile Precompile executables in immediate dependencies. | ||||||
--tighten Updates lower bounds in pubspec.yaml to match the resolved version. | ||||||
--[no-]transitive Also upgrades the transitive dependencies of the listed [dependencies] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
--major-versions Upgrades packages to their latest resolvable versions, and updates pubspec.yaml. | ||||||
-C, --directory=<dir> Run this in the directory <dir>. | ||||||
|
||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:test/test.dart'; | ||
|
||
import '../descriptor.dart' as d; | ||
import '../test_pub.dart'; | ||
|
||
void main() { | ||
test('without --unlock-transitive, the transitive dependencies stay locked', | ||
() async { | ||
final server = await servePackages(); | ||
server.serve('foo', '1.0.0', deps: {'bar': '^1.0.0'}); | ||
server.serve('bar', '1.0.0'); | ||
|
||
await d.appDir( | ||
dependencies: { | ||
'foo': '^1.0.0', | ||
}, | ||
).create(); | ||
|
||
await pubGet(output: contains('+ foo 1.0.0')); | ||
|
||
server.serve('foo', '1.5.0', deps: {'bar': '^1.0.0'}); | ||
server.serve('bar', '1.5.0'); | ||
|
||
await pubUpgrade( | ||
args: ['foo'], | ||
output: allOf( | ||
contains('> foo 1.5.0'), | ||
isNot(contains('bar')), | ||
), | ||
); | ||
}); | ||
|
||
test('`--unlock-transitive` dependencies gets unlocked', () async { | ||
final server = await servePackages(); | ||
server.serve('foo', '1.0.0', deps: {'bar': '^1.0.0'}); | ||
server.serve('bar', '1.0.0'); | ||
server.serve('baz', '1.0.0'); | ||
|
||
await d.appDir( | ||
dependencies: { | ||
'foo': '^1.0.0', | ||
'baz': '^1.0.0', | ||
}, | ||
).create(); | ||
|
||
await pubGet(output: contains('+ foo 1.0.0')); | ||
|
||
server.serve('foo', '1.5.0', deps: {'bar': '^1.0.0'}); | ||
server.serve('bar', '1.5.0'); | ||
server.serve('baz', '1.5.0'); | ||
|
||
await pubUpgrade( | ||
args: ['--unlock-transitive', 'foo'], | ||
output: allOf( | ||
contains('> foo 1.5.0'), | ||
contains('> bar 1.5.0'), | ||
isNot( | ||
contains('baz 1.5.0'), | ||
), // Baz is not a transitive dependency of bar | ||
), | ||
); | ||
}); | ||
|
||
test( | ||
'`--major-versions` without `--unlock-transitive` does not allow ' | ||
'transitive dependencies to be upgraded along with the named packages', | ||
() async { | ||
final server = await servePackages(); | ||
server.serve('foo', '1.0.0', deps: {'bar': '^1.0.0'}); | ||
server.serve('bar', '1.0.0'); | ||
|
||
await d.appDir( | ||
dependencies: { | ||
'foo': '^1.0.0', | ||
}, | ||
).create(); | ||
|
||
await pubGet(output: contains('+ foo 1.0.0')); | ||
|
||
server.serve('foo', '2.0.0', deps: {'bar': '^1.0.0'}); | ||
server.serve('bar', '1.5.0'); | ||
|
||
await pubUpgrade( | ||
args: ['--major-versions', 'foo'], | ||
output: allOf( | ||
contains('> foo 2.0.0'), | ||
isNot(contains('bar 1.5.0')), | ||
), | ||
); | ||
}); | ||
|
||
test( | ||
'`--unlock-transitive --major-versions` allows transitive dependencies ' | ||
'be upgraded along with the named packages', () async { | ||
final server = await servePackages(); | ||
server.serve('foo', '1.0.0', deps: {'bar': '^1.0.0'}); | ||
server.serve('bar', '1.0.0'); | ||
server.serve('baz', '1.0.0'); | ||
|
||
await d.appDir( | ||
dependencies: { | ||
'foo': '^1.0.0', | ||
'baz': '^1.0.0', | ||
}, | ||
).create(); | ||
|
||
await pubGet(output: contains('+ foo 1.0.0')); | ||
|
||
server.serve('foo', '2.0.0', deps: {'bar': '^1.0.0'}); | ||
server.serve('bar', '1.5.0'); | ||
server.serve('baz', '1.5.0'); | ||
|
||
await pubUpgrade( | ||
args: ['--major-versions', '--unlock-transitive', 'foo'], | ||
output: allOf( | ||
contains('> foo 2.0.0'), | ||
contains('> bar 1.5.0'), | ||
isNot(contains('> baz 1.5.0')), | ||
), | ||
); | ||
}); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.