@@ -586,7 +586,7 @@ class Dub {
586
586
587
587
FetchOptions fetchOpts;
588
588
fetchOpts |= (options & UpgradeOptions.preRelease) != 0 ? FetchOptions.usePrerelease : FetchOptions.none;
589
- if (! pack) fetch(p, ver, defaultPlacementLocation, fetchOpts, " getting selected version" );
589
+ if (! pack) fetch(p, ver.version_ , defaultPlacementLocation, fetchOpts, " getting selected version" );
590
590
if ((options & UpgradeOptions.select) && p != m_project.rootPackage.name) {
591
591
if (! ver.repository.empty) {
592
592
m_project.selections.selectVersion(p, ver.repository);
@@ -664,7 +664,7 @@ class Dub {
664
664
if (! tool_pack) tool_pack = m_packageManager.getBestPackage(tool, " ~master" );
665
665
if (! tool_pack) {
666
666
logInfo(" Hint" , Color.light_blue, " %s is not present, getting and storing it user wide" , tool);
667
- tool_pack = fetch(tool, Dependency.any , defaultPlacementLocation, FetchOptions.none);
667
+ tool_pack = fetch(tool, VersionRange.Any , defaultPlacementLocation, FetchOptions.none);
668
668
}
669
669
670
670
auto dscanner_dub = new Dub(null , m_packageSuppliers);
@@ -738,14 +738,31 @@ class Dub {
738
738
}
739
739
740
740
// / Fetches the package matching the dependency and places it in the specified location.
741
+ deprecated (" Use the overload that accepts either a `Version` or a `VersionRange` as second argument" )
741
742
Package fetch (string packageId, const Dependency dep, PlacementLocation location, FetchOptions options, string reason = " " )
743
+ {
744
+ const vrange = dep.visit! (
745
+ (VersionRange range) => range,
746
+ (any) => throw new Exception (" Cannot call `dub.fetch` with a " ~ typeof (any).stringof ~ " dependency" ),
747
+ );
748
+ return this .fetch(packageId, vrange, location, options, reason);
749
+ }
750
+
751
+ // / Ditto
752
+ Package fetch (string packageId, in Version vers, PlacementLocation location, FetchOptions options, string reason = " " )
753
+ {
754
+ return this .fetch(packageId, VersionRange(vers, vers), location, options, reason);
755
+ }
756
+
757
+ // / Ditto
758
+ Package fetch (string packageId, in VersionRange range, PlacementLocation location, FetchOptions options, string reason = " " )
742
759
{
743
760
auto basePackageName = getBasePackageName(packageId);
744
761
Json pinfo;
745
762
PackageSupplier supplier;
746
763
foreach (ps; m_packageSuppliers){
747
764
try {
748
- pinfo = ps.fetchPackageRecipe(basePackageName, dep , (options & FetchOptions.usePrerelease) != 0 );
765
+ pinfo = ps.fetchPackageRecipe(basePackageName, Dependency(range) , (options & FetchOptions.usePrerelease) != 0 );
749
766
if (pinfo.type == Json.Type.null_)
750
767
continue ;
751
768
supplier = ps;
@@ -755,7 +772,7 @@ class Dub {
755
772
logDebug(" Full error: %s" , e.toString().sanitize());
756
773
}
757
774
}
758
- enforce(pinfo.type != Json.Type.undefined, " No package " ~ packageId~ " was found matching the dependency " ~ dep .toString());
775
+ enforce(pinfo.type != Json.Type.undefined, " No package " ~ packageId~ " was found matching the dependency " ~ range .toString());
759
776
string ver = pinfo[" version" ].get ! string ;
760
777
761
778
NativePath placement;
@@ -813,7 +830,7 @@ class Dub {
813
830
import std.zip : ZipException ;
814
831
815
832
auto path = getTempFile(basePackageName, " .zip" );
816
- supplier.fetchPackage(path, basePackageName, dep , (options & FetchOptions.usePrerelease) != 0 ); // Q: continue on fail?
833
+ supplier.fetchPackage(path, basePackageName, Dependency(range) , (options & FetchOptions.usePrerelease) != 0 ); // Q: continue on fail?
817
834
scope (exit) std.file.remove (path.toNativeString());
818
835
logDiagnostic(" Placing to %s..." , placement.toNativeString());
819
836
@@ -1142,7 +1159,7 @@ class Dub {
1142
1159
if (! template_pack) template_pack = m_packageManager.getBestPackage(packageName, " ~master" );
1143
1160
if (! template_pack) {
1144
1161
logInfo(" %s is not present, getting and storing it user wide" , packageName);
1145
- template_pack = fetch(packageName, Dependency.any , defaultPlacementLocation, FetchOptions.none);
1162
+ template_pack = fetch(packageName, VersionRange.Any , defaultPlacementLocation, FetchOptions.none);
1146
1163
}
1147
1164
1148
1165
Package initSubPackage = m_packageManager.getSubPackage(template_pack, " init-exec" , false );
@@ -1210,7 +1227,7 @@ class Dub {
1210
1227
if (! tool_pack) tool_pack = m_packageManager.getBestPackage(tool, " ~master" );
1211
1228
if (! tool_pack) {
1212
1229
logInfo(" %s is not present, getting and storing it user wide" , tool);
1213
- tool_pack = fetch(tool, Dependency.any , defaultPlacementLocation, FetchOptions.none);
1230
+ tool_pack = fetch(tool, VersionRange.Any , defaultPlacementLocation, FetchOptions.none);
1214
1231
}
1215
1232
1216
1233
auto ddox_dub = new Dub(null , m_packageSuppliers);
@@ -1673,11 +1690,12 @@ private class DependencyVersionResolver : DependencyResolver!(Dependency, Depend
1673
1690
return null ;
1674
1691
}
1675
1692
}
1693
+ const vers = dep.version_;
1676
1694
1677
1695
if (auto ret = m_dub.m_packageManager.getBestPackage(name, dep))
1678
1696
return ret;
1679
1697
1680
- auto key = name ~ " :" ~ dep.version_ .toString();
1698
+ auto key = name ~ " :" ~ vers .toString();
1681
1699
if (auto ret = key in m_remotePackages)
1682
1700
return * ret;
1683
1701
@@ -1695,15 +1713,15 @@ private class DependencyVersionResolver : DependencyResolver!(Dependency, Depend
1695
1713
m_remotePackages[key] = ret;
1696
1714
return ret;
1697
1715
} catch (Exception e) {
1698
- logDiagnostic(" Metadata for %s %s could not be downloaded from %s: %s" , name, dep , ps.description, e.msg);
1716
+ logDiagnostic(" Metadata for %s %s could not be downloaded from %s: %s" , name, vers , ps.description, e.msg);
1699
1717
logDebug(" Full error: %s" , e.toString().sanitize);
1700
1718
}
1701
1719
} else {
1702
- logDiagnostic(" Package %s not found in base package description (%s). Downloading whole package." , name, dep.version_ .toString());
1720
+ logDiagnostic(" Package %s not found in base package description (%s). Downloading whole package." , name, vers .toString());
1703
1721
try {
1704
1722
FetchOptions fetchOpts;
1705
1723
fetchOpts |= prerelease ? FetchOptions.usePrerelease : FetchOptions.none;
1706
- m_dub.fetch(rootpack, dep , m_dub.defaultPlacementLocation, fetchOpts, " need sub package description" );
1724
+ m_dub.fetch(rootpack, vers , m_dub.defaultPlacementLocation, fetchOpts, " need sub package description" );
1707
1725
auto ret = m_dub.m_packageManager.getBestPackage(name, dep);
1708
1726
if (! ret) {
1709
1727
logWarn(" Package %s %s doesn't have a sub package %s" , rootpack, dep.version_, name);
0 commit comments