Skip to content

Commit

Permalink
Merge branch 'master' into fix/line-splitting-todo
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdm authored Aug 23, 2024
2 parents a2cb574 + 31fa75b commit c9c37d7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/src/entrypoint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,12 @@ See https://dart.dev/go/sdk-constraint

final toTighten = <(Package, PackageRange)>[];

// Keep track of the versions of workspace packages - these are not included
// in the lockfile.
final workspaceVersions = <String, Version>{};

for (final package in workspaceRoot.transitiveWorkspace) {
workspaceVersions[package.name] = package.version;
if (packagesToUpgrade.isEmpty) {
for (final range in [
...package.dependencies.values,
Expand All @@ -1400,10 +1405,12 @@ See https://dart.dev/go/sdk-constraint
for (final (package, range) in toTighten) {
final changesForPackage = result[package] ??= {};
final constraint = (changesForPackage[range] ?? range).constraint;

final resolvedVersion =
(packageVersions?.firstWhere((p) => p.name == range.name) ??
lockFile.packages[range.name])!
.version;
lockFile.packages[range.name])
?.version ??
workspaceVersions[range.name]!;
if (range.source is HostedSource && constraint.isAny) {
changesForPackage[range] = range
.toRef()
Expand Down
31 changes: 31 additions & 0 deletions test/downgrade/tighten_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,35 @@ void main() {
),
);
});

test('--tighten works for workspace with internal dependencies', () async {
await servePackages();

await d.dir(appPath, [
d.libPubspec(
'myapp',
'1.2.3',
extras: {
'workspace': ['pkgs/a'],
},
sdk: '^3.5.0',
),
d.dir('pkgs', [
d.dir('a', [
d.libPubspec(
'a',
'1.1.1',
deps: {'myapp': '^1.0.0'},
resolutionWorkspace: true,
),
]),
]),
]).create();

await pubDowngrade(
args: ['--tighten'],
output: contains('myapp: ^1.0.0 -> ^1.2.3'),
environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
);
});
}

0 comments on commit c9c37d7

Please sign in to comment.