diff --git a/source/dub/dub.d b/source/dub/dub.d index 1eeea9cdb..d46903525 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -639,7 +639,7 @@ class Dub { try if (m_packageManager.getOrLoadPackage(path)) continue; catch (Exception e) { logDebug("Failed to load path based selection: %s", e.toString().sanitize); } } else if (!dep.repository.empty) { - if (m_packageManager.loadSCMPackage(name.toString(), dep.repository)) + if (m_packageManager.loadSCMPackage(name, dep.repository)) continue; } else { if (m_packageManager.getPackage(p, dep.version_)) continue; @@ -703,7 +703,7 @@ class Dub { continue; } } else if (!ver.repository.empty) { - pack = m_packageManager.loadSCMPackage(name.toString(), ver.repository); + pack = m_packageManager.loadSCMPackage(name, ver.repository); } else { assert(ver.isExactVersion, "Resolved dependency is neither path, nor repository, nor exact version based!?"); pack = m_packageManager.getPackage(p, ver.version_); @@ -1934,7 +1934,7 @@ private class DependencyVersionResolver : DependencyResolver!(Dependency, Depend return m_rootPackage.basePackage; if (!dep.repository.empty) { - auto ret = m_dub.packageManager.loadSCMPackage(name.toString(), dep.repository); + auto ret = m_dub.packageManager.loadSCMPackage(name, dep.repository); return ret !is null && dep.matches(ret.version_) ? ret : null; } if (!dep.path.empty) { diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index 7bc51c4ca..ab20acc46 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -398,22 +398,15 @@ class PackageManager { The package loaded from the given SCM repository or null if the package couldn't be loaded. */ - deprecated("Use the overload that accepts a `dub.dependency : Repository`") - Package loadSCMPackage(string name, Dependency dependency) - in { assert(!dependency.repository.empty); } - do { return this.loadSCMPackage(name, dependency.repository); } - - /// Ditto - Package loadSCMPackage(string name, Repository repo) + Package loadSCMPackage(in PackageName name, in Repository repo) in { assert(!repo.empty); } do { Package pack; - const name_ = PackageName(name); final switch (repo.kind) { case repo.Kind.git: - pack = loadGitPackage(name_, repo); + pack = loadGitPackage(name, repo); } if (pack !is null) { addPackages(this.m_internal.fromPath, pack); @@ -421,6 +414,17 @@ class PackageManager { return pack; } + deprecated("Use the overload that accepts a `dub.dependency : Repository`") + Package loadSCMPackage(string name, Dependency dependency) + in { assert(!dependency.repository.empty); } + do { return this.loadSCMPackage(name, dependency.repository); } + + deprecated("Use `loadSCMPackage(PackageName, Repository)`") + Package loadSCMPackage(string name, Repository repo) + { + return this.loadSCMPackage(PackageName(name), repo); + } + private Package loadGitPackage(in PackageName name, in Repository repo) { import dub.internal.git : cloneRepository; diff --git a/source/dub/project.d b/source/dub/project.d index fe42ecf6c..67898d0ef 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -562,7 +562,7 @@ class Project { return resolveSubPackage(tmp, subname, true); }, (Repository repo) { - auto tmp = m_packageManager.loadSCMPackage(basename.toString(), repo); + auto tmp = m_packageManager.loadSCMPackage(basename, repo); return resolveSubPackage(tmp, subname, true); }, (VersionRange range) { @@ -585,7 +585,7 @@ class Project { if (p is null) { if (!vspec.repository.empty) { - p = m_packageManager.loadSCMPackage(basename.toString(), vspec.repository); + p = m_packageManager.loadSCMPackage(basename, vspec.repository); resolveSubPackage(p, subname, false); enforce(p !is null, "Unable to fetch '%s@%s' using git - does the repository and version exists?".format( diff --git a/source/dub/test/base.d b/source/dub/test/base.d index a268eca63..1b1c47886 100644 --- a/source/dub/test/base.d +++ b/source/dub/test/base.d @@ -281,6 +281,9 @@ package class TestPackageManager : PackageManager super(local, user, system, false); } + // Re-introduce hidden/deprecated overloads + public alias loadSCMPackage = PackageManager.loadSCMPackage; + /// Disabled as semantic are not implementable unless a virtual FS is created public override @property void customCachePaths(NativePath[] custom_cache_paths) { @@ -326,7 +329,7 @@ package class TestPackageManager : PackageManager * Instead, we allow unittests to explicitly define what packages should be * reachable in a given test. */ - public override Package loadSCMPackage(string name, Repository repo) + public override Package loadSCMPackage(in PackageName name, in Repository repo) { import std.string : chompPrefix; @@ -334,11 +337,10 @@ package class TestPackageManager : PackageManager if (!repo.ref_.startsWith("~") && !repo.ref_.isGitHash) return null; - const name_ = PackageName(name); string gitReference = repo.ref_.chompPrefix("~"); - NativePath destination = this.getPackagePath(PlacementLocation.user, name_, repo.ref_); + NativePath destination = this.getPackagePath(PlacementLocation.user, name, repo.ref_); - foreach (p; getPackageIterator(name)) + foreach (p; getPackageIterator(name.toString())) if (p.path == destination) return p; @@ -346,7 +348,7 @@ package class TestPackageManager : PackageManager } /// The private part of `loadSCMPackage` - protected Package loadSCMRepository(string name, Repository repo) + protected Package loadSCMRepository(in PackageName name, in Repository repo) { if (auto prepo = repo in this.scm) { this.add(*prepo);