Skip to content

Commit

Permalink
Fix version match rules for add-path based packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Nov 4, 2022
1 parent 47d9b98 commit 1f17d28
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions source/dub/packagemanager.d
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ class PackageManager {
* A `Package` if one was found, `null` if none exists.
*/
private Package lookup (string name, Version vers) {
if (auto pkg = this.m_internal.lookup(name, vers))
if (!this.m_initialized)
this.refresh();

if (auto pkg = this.m_internal.lookup(name, vers, this))
return pkg;

foreach (ref location; this.m_repositories)
Expand Down Expand Up @@ -493,7 +496,7 @@ class PackageManager {
Managed packages can be upgraded and removed.
*/
bool isManagedPackage(Package pack)
bool isManagedPackage(const(Package) pack)
const {
auto ppath = pack.basePackage.path;
return isManagedPath(ppath);
Expand Down Expand Up @@ -1356,13 +1359,15 @@ private struct Location {
* Returns:
* A `Package` if one was found, `null` if none exists.
*/
private inout(Package) lookup(string name, Version ver) inout {
private inout(Package) lookup(string name, Version ver, PackageManager mgr) inout {
foreach (pkg; this.localPackages)
if (pkg.name == name && pkg.version_.matches(ver, VersionMatchMode.strict))
if (pkg.name == name && pkg.version_.matches(ver, VersionMatchMode.standard))
return pkg;
foreach (pkg; this.fromPath)
if (pkg.name == name && pkg.version_.matches(ver, VersionMatchMode.strict))
foreach (pkg; this.fromPath) {
auto pvm = mgr.isManagedPackage(pkg) ? VersionMatchMode.strict : VersionMatchMode.standard;
if (pkg.name == name && pkg.version_.matches(ver, pvm))
return pkg;
}
return null;
}

Expand All @@ -1383,7 +1388,7 @@ private struct Location {
*/
private Package load (string name, Version vers, PackageManager mgr)
{
if (auto pkg = this.lookup(name, vers))
if (auto pkg = this.lookup(name, vers, mgr))
return pkg;

string versStr = vers.toString();
Expand Down

0 comments on commit 1f17d28

Please sign in to comment.