Skip to content

Commit bf13542

Browse files
committed
Deprecate Dub.getPackageSuppliers
As it really should be an implementation details (only called from the ctors), and the name is misleading as it reads the environment and the config.
1 parent 1122e94 commit bf13542

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

source/dub/dub.d

+17-10
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class Dub {
162162

163163
init(m_rootPath);
164164

165-
m_packageSuppliers = getPackageSuppliers(additional_package_suppliers, skip_registry);
165+
m_packageSuppliers = this.computePkgSuppliers(additional_package_suppliers, skip_registry);
166166
m_packageManager = new PackageManager(m_rootPath, m_dirs.localRepository, m_dirs.systemSettings);
167167

168168
auto ccps = m_config.customCachePaths;
@@ -249,7 +249,16 @@ class Dub {
249249
skip_registry = Can be used to skip using the configured package
250250
suppliers, as well as the default suppliers.
251251
*/
252+
deprecated("This is an implementation detail. " ~
253+
"Use `packageSuppliers` to get the computed list of package " ~
254+
"suppliers once a `Dub` instance has been constructed.")
252255
public PackageSupplier[] getPackageSuppliers(PackageSupplier[] additional_package_suppliers, SkipPackageSuppliers skip_registry)
256+
{
257+
return this.computePkgSuppliers(additional_package_suppliers, skip_registry);
258+
}
259+
260+
/// Ditto
261+
private PackageSupplier[] computePkgSuppliers(PackageSupplier[] additional_package_suppliers, SkipPackageSuppliers skip_registry)
253262
{
254263
PackageSupplier[] ps = additional_package_suppliers;
255264

@@ -275,6 +284,9 @@ class Dub {
275284
}
276285

277286
/// ditto
287+
deprecated("This is an implementation detail. " ~
288+
"Use `packageSuppliers` to get the computed list of package " ~
289+
"suppliers once a `Dub` instance has been constructed.")
278290
public PackageSupplier[] getPackageSuppliers(PackageSupplier[] additional_package_suppliers)
279291
{
280292
return getPackageSuppliers(additional_package_suppliers, m_config.skipRegistry);
@@ -285,17 +297,12 @@ class Dub {
285297
scope (exit) environment.remove("DUB_REGISTRY");
286298
auto dub = new Dub(".", null, SkipPackageSuppliers.none);
287299

288-
dub.m_config.skipRegistry = typeof(dub.m_config.skipRegistry)(SkipPackageSuppliers.none);
289-
assert(dub.getPackageSuppliers(null).length == 1);
290-
291-
dub.m_config.skipRegistry = typeof(dub.m_config.skipRegistry)(SkipPackageSuppliers.configured);
292-
assert(dub.getPackageSuppliers(null).length == 0);
293-
294-
dub.m_config.skipRegistry = typeof(dub.m_config.skipRegistry)(SkipPackageSuppliers.standard);
295-
assert(dub.getPackageSuppliers(null).length == 0);
300+
assert(dub.computePkgSuppliers(null, SkipPackageSuppliers.none).length == 1);
301+
assert(dub.computePkgSuppliers(null, SkipPackageSuppliers.configured).length == 0);
302+
assert(dub.computePkgSuppliers(null, SkipPackageSuppliers.standard).length == 0);
296303

297304
environment["DUB_REGISTRY"] = "http://example.com/";
298-
assert(dub.getPackageSuppliers(null).length == 1);
305+
assert(dub.computePkgSuppliers(null, SkipPackageSuppliers.standard).length == 1);
299306
}
300307

301308
@property bool dryRun() const { return m_dryRun; }

0 commit comments

Comments
 (0)