Skip to content

Commit 9d5fd4f

Browse files
Geod24dlang-bot
authored andcommitted
PackageManager: Deprecate overloads of getPackage with string version
1 parent 860b806 commit 9d5fd4f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

source/dub/dub.d

+4-4
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ class Dub {
779779
}
780780
}
781781
enforce(pinfo.type != Json.Type.undefined, "No package "~packageId~" was found matching the dependency " ~ range.toString());
782-
string ver = pinfo["version"].get!string;
782+
Version ver = Version(pinfo["version"].get!string);
783783

784784
NativePath placement;
785785
final switch (location) {
@@ -791,15 +791,15 @@ class Dub {
791791
// always upgrade branch based versions - TODO: actually check if there is a new commit available
792792
Package existing = m_packageManager.getPackage(packageId, ver, placement);
793793
if (options & FetchOptions.printOnly) {
794-
if (existing && existing.version_ != Version(ver))
794+
if (existing && existing.version_ != ver)
795795
logInfo("A new version for %s is available (%s -> %s). Run \"%s\" to switch.",
796796
packageId.color(Mode.bold), existing.version_, ver,
797797
text("dub upgrade ", packageId).color(Mode.bold));
798798
return null;
799799
}
800800

801801
if (existing) {
802-
if (!ver.startsWith("~") || !(options & FetchOptions.forceBranchUpgrade) || location == PlacementLocation.local) {
802+
if (!ver.isBranch() || !(options & FetchOptions.forceBranchUpgrade) || location == PlacementLocation.local) {
803803
// TODO: support git working trees by performing a "git pull" instead of this
804804
logDiagnostic("Package %s %s (%s) is already present with the latest version, skipping upgrade.",
805805
packageId, ver, placement);
@@ -816,7 +816,7 @@ class Dub {
816816

817817
logDebug("Acquiring package zip file");
818818

819-
NativePath dstpath = PackageManager.getPackagePath(placement, basePackageName, ver);
819+
NativePath dstpath = PackageManager.getPackagePath(placement, basePackageName, ver.toString());
820820
if (!dstpath.existsFile())
821821
mkdirRecurse(dstpath.toNativeString());
822822
// For libraries leaking their import path

source/dub/packagemanager.d

+2
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ class PackageManager {
190190
}
191191

192192
/// ditto
193+
deprecated("Use the overload that accepts a `Version` as second argument")
193194
Package getPackage(string name, string ver, bool enable_overrides = true)
194195
{
195196
return getPackage(name, Version(ver), enable_overrides);
@@ -207,6 +208,7 @@ class PackageManager {
207208
}
208209

209210
/// ditto
211+
deprecated("Use the overload that accepts a `Version` as second argument")
210212
Package getPackage(string name, string ver, NativePath path)
211213
{
212214
return getPackage(name, Version(ver), path);

0 commit comments

Comments
 (0)