diff --git a/source/app.d b/source/app.d index 8bdd97d..4095984 100644 --- a/source/app.d +++ b/source/app.d @@ -159,15 +159,15 @@ auto location = InstallLocation.userWide; auto name = args[1]; enforce(!install_local || !install_system, "Cannot install locally and system wide at the same time."); - if( install_local ) location = InstallLocation.local; - else if( install_system ) location = InstallLocation.systemWide; - if( install_version.length ) dub.install(name, Dependency(install_version), location); + if (install_local) location = InstallLocation.local; + else if (install_system) location = InstallLocation.systemWide; + if (install_version.length) dub.install(name, Dependency(install_version), location, true); else { - try dub.install(name, Dependency(">=0.0.0"), location); + try dub.install(name, Dependency(">=0.0.0"), location, true); catch(Exception e){ logInfo("Installing a release version failed: %s", e.msg); logInfo("Retry with ~master..."); - dub.install(name, Dependency("~master"), location); + dub.install(name, Dependency("~master"), location, true); } } break; diff --git a/source/dub/dub.d b/source/dub/dub.d index 8ba3652..1d0ac8d 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -146,13 +146,9 @@ uninstall(a.pack); } foreach(Action a; filter!((Action a) => a.type == Action.Type.install)(actions)) { - install(a.packageId, a.vers, a.location); - if(a.vers.matches(Version.MASTER())) { - // Currently, there is no possibility to note when the - // module was updated last. Therefore we update a single - // package only once per update command. - masterVersionUpgrades[a.packageId] = true; - } + install(a.packageId, a.vers, a.location, (options & UpdateOptions.Upgrade) != 0); + // never update the same package more than once + masterVersionUpgrades[a.packageId] = true; } m_project.reinit(); @@ -184,7 +180,7 @@ string[string] installedPackages() const { return m_project.installedPackagesIDs(); } /// Installs the package matching the dependency into the application. - Package install(string packageId, const Dependency dep, InstallLocation location) + Package install(string packageId, const Dependency dep, InstallLocation location, bool force_branch_upgrade) { Json pinfo; PackageSupplier supplier; @@ -207,7 +203,8 @@ // always upgrade branch based versions - TODO: actually check if there is a new commit available if (auto pack = m_packageManager.getPackage(packageId, ver, install_path)) { - if (!ver.startsWith("~")) { + if (!ver.startsWith("~") || !force_branch_upgrade || location == InstallLocation.local) { + // TODO: support git working trees by performing a "git pull" instead of this logInfo("Package %s %s (%s) is already installed with the latest version, skipping upgrade.", packageId, ver, install_path); return pack; @@ -381,7 +378,7 @@ if (!ddox_pack) ddox_pack = m_packageManager.getBestPackage("ddox", "~master"); if (!ddox_pack) { logInfo("DDOX is not installed, performing user wide installation."); - ddox_pack = install("ddox", Dependency(">=0.0.0"), InstallLocation.userWide); + ddox_pack = install("ddox", Dependency(">=0.0.0"), InstallLocation.userWide, false); } version(Windows) auto ddox_exe = "ddox.exe";