Ignore `pubspec_overrides.yaml` for `publish` command (#3419)
Fixes #3393
diff --git a/lib/src/command.dart b/lib/src/command.dart
index ee62392..240a15e 100644
--- a/lib/src/command.dart
+++ b/lib/src/command.dart
@@ -73,7 +73,12 @@
///
/// This will load the pubspec and fail with an error if the current directory
/// is not a package.
- late final Entrypoint entrypoint = Entrypoint(directory, cache);
+ late final Entrypoint entrypoint =
+ Entrypoint(directory, cache, withPubspecOverrides: withPubspecOverrides);
+
+ /// Whether `pubspec_overrides.yaml` is taken into account, when creating
+ /// [entrypoint].
+ bool get withPubspecOverrides => true;
/// The URL for web documentation for this command.
String? get docUrl => null;
diff --git a/lib/src/command/lish.dart b/lib/src/command/lish.dart
index a20fbdf..947c886 100644
--- a/lib/src/command/lish.dart
+++ b/lib/src/command/lish.dart
@@ -32,6 +32,8 @@
String get docUrl => 'https://dart.dev/tools/pub/cmd/pub-lish';
@override
bool get takesArguments => false;
+ @override
+ bool get withPubspecOverrides => false;
/// The URL of the server to which to upload the package.
late final Uri host = () {
@@ -169,8 +171,8 @@
};
// Using OAuth2 authentication client for the official pub servers
- final isOfficalServer = officialPubServers.contains(host.toString());
- if (isOfficalServer && !cache.tokenStore.hasCredential(host)) {
+ final isOfficialServer = officialPubServers.contains(host.toString());
+ if (isOfficialServer && !cache.tokenStore.hasCredential(host)) {
// Using OAuth2 authentication client for the official pub servers, when
// we don't have an explicit token from [TokenStore] to use instead.
//
diff --git a/lib/src/entrypoint.dart b/lib/src/entrypoint.dart
index ac7ff51..c17d7e8 100644
--- a/lib/src/entrypoint.dart
+++ b/lib/src/entrypoint.dart
@@ -187,9 +187,10 @@
/// Loads the entrypoint from a package at [rootDir].
Entrypoint(
String rootDir,
- this.cache,
- ) : root = Package.load(null, rootDir, cache.sources,
- withPubspecOverrides: true),
+ this.cache, {
+ bool withPubspecOverrides = true,
+ }) : root = Package.load(null, rootDir, cache.sources,
+ withPubspecOverrides: withPubspecOverrides),
globalDir = null;
Entrypoint.inMemory(this.root, this.cache,
diff --git a/test/pubspec_overrides_test.dart b/test/pubspec_overrides_test.dart
index 2e9234f..514d52f 100644
--- a/test/pubspec_overrides_test.dart
+++ b/test/pubspec_overrides_test.dart
@@ -2,6 +2,7 @@
// 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:pub/src/exit_codes.dart' as exit_codes;
import 'package:test/test.dart';
import 'descriptor.dart' as d;
@@ -9,7 +10,7 @@
void main() {
forBothPubGetAndUpgrade((command) {
- test('pubspec overrides', () async {
+ test('supports dependency_overrides', () async {
await servePackages()
..serve('lib', '1.0.0')
..serve('lib', '2.0.0');
@@ -46,4 +47,18 @@
]).validate();
});
});
+
+ test('is ignored by publish command', () async {
+ await d.validPackage.create();
+ await d.dir(appPath, [
+ d.pubspecOverrides({
+ 'dependency_overrides': {'lib': '1.0.0'}
+ }),
+ ]).create();
+
+ await runPub(
+ args: ['lish', '--dry-run'],
+ exitCode: exit_codes.SUCCESS,
+ );
+ });
}