Skip to content
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

Don't iterate above the root dir when finding stray pubspecs #4469

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/src/package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,10 @@ Package `$override` at `${overriddenWorkspacePackage.presentationDir}` is overri
// By adding this to visited we will never go above the workspaceRoot.dir.
p.canonicalize(root.dir),
};
for (final package in root.transitiveWorkspace) {
for (final package in root.transitiveWorkspace
// We don't want to look at the roots parents. The first package is always
// the root, so skip that.
.skip(1)) {
// Run through all parent directories until we meet another workspace
// package.
for (final dir in parentDirs(package.dir).skip(1)) {
Expand Down
14 changes: 7 additions & 7 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ packages:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab"
sha256: "45cfa8471b89fb6643fe9bf51bd7931a76b8f5ec2d65de4fb176dba8d4f22c77"
url: "https://pub.dev"
source: hosted
version: "76.0.0"
version: "73.0.0"
_macros:
dependency: transitive
description: dart
source: sdk
version: "0.3.3"
version: "0.3.2"
analyzer:
dependency: "direct main"
description:
name: analyzer
sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e"
sha256: "4959fec185fe70cce007c57e9ab6983101dbe593d2bf8bbfb4453aaec0cf470a"
url: "https://pub.dev"
source: hosted
version: "6.11.0"
version: "6.8.0"
args:
dependency: "direct main"
description:
Expand Down Expand Up @@ -194,10 +194,10 @@ packages:
dependency: transitive
description:
name: macros
sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656"
sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536"
url: "https://pub.dev"
source: hosted
version: "0.1.3-main.0"
version: "0.1.2-main.4"
matcher:
dependency: transitive
description:
Expand Down
66 changes: 66 additions & 0 deletions test/workspace_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,72 @@ Consider removing one of the overrides.''',
);
});

test(
'rejects workspace with non-workspace between root and workspace package',
() async {
await dir(appPath, [
libPubspec(
'myapp',
'1.2.3',
extras: {
'workspace': ['pkgs/a'],
},
sdk: '^3.5.0',
),
dir('pkgs', [
libPubspec(
'in_the_way',
'1.0.0',
),
dir('a', [
libPubspec(
'a',
'1.0.0',
resolutionWorkspace: true,
),
]),
]),
]).create();
await pubGet(
environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
error: contains(
'The file `.${s}pkgs${s}pubspec.yaml` is located in a directory '
'between the workspace root at',
),
);
});

test('Doesn\t complain about pubspecs above the workspace', () async {
// Regression test for https://github.com/dart-lang/pub/issues/4463
await dir(appPath, [
libPubspec(
'not_in_the_way',
'1.0.0',
),
dir('pkgs', [
libPubspec(
'myapp',
'1.2.3',
extras: {
'workspace': ['a'],
},
sdk: '^3.5.0',
),
dir('a', [
libPubspec(
'a',
'1.0.0',
resolutionWorkspace: true,
),
]),
]),
]).create();
await pubGet(
environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
workingDirectory: p.join(sandbox, appPath, 'pkgs'),
);
});

test('overrides are applied', () async {
final server = await servePackages();
server.serve('foo', '1.0.0');
Expand Down
Loading