chocolatey / choco

Chocolatey - the package manager for Windows
https://chocolatey.org
Other
10.24k stars 897 forks source link

`upgrade -noop` counts out-of-date packages incorrectly #97

Closed chucker closed 9 years ago

chucker commented 9 years ago

Example:

PS C:\Windows\system32> choco upgrade all -pre -noop
Chocolatey v0.9.9.0
_ Chocolatey:ChocolateyUpgradeCommand - Noop Mode _
You have autohotkey.portable v1.1.19.02 installed. Version 1.1.19.03 is available based on your source(s)
temp_BoxstarterPackage was not found with the source(s) listed.
 If you specified a particular version and are receiving this message, it is possible that the package name exists but t
he version does not.
 Version: ""
 Source(s): "https://chocolatey.org/api/v2/"
dotTrace v6.0.1 is the latest version available based on your source(s).
AnkhSvn v2.5.12582 is the latest version available based on your source(s).
dotMemory v4.2.1 is the latest version available based on your source(s).
google-chrome-x64 v40.0.2214.111 is the latest version available based on your source(s).
winscp v5.5.6 is the latest version available based on your source(s).
winmerge v2.14.0 is the latest version available based on your source(s).
dotPeek v1.3 is the latest version available based on your source(s).
tortoisesvn v1.8.10 is the latest version available based on your source(s).
You have fiddler4 v4.4.9.8 installed. Version 4.4.9.9 is available based on your source(s)
SourceTree v1.6.11 is the latest version available based on your source(s).
resharper-platform v1.0.1 is the latest version available based on your source(s).
sysinternals v2015.01.29 is the latest version available based on your source(s).
grepwin v1.6.6 is the latest version available based on your source(s).
snaketail v1.8.2 is the latest version available based on your source(s).
You have dropbox v3.2.4 installed. Version 3.2.6 is available based on your source(s)
meld v3.12.3 is the latest version available based on your source(s).
7zip.install v9.22.01.20130618 is the latest version available based on your source(s).
windirstat v1.1.2.20140225 is the latest version available based on your source(s).
DotNet4.5 v4.5.20120822 is the latest version available based on your source(s).
chocolatey v0.9.9-rc5 is the latest version available based on your source(s).
1password v4.1.0.538 is the latest version available based on your source(s).

There are 20 packages available for upgrade.
 See the log for details.

It appears to count all packages, rather than the ones for which there is a newer version.

chucker commented 9 years ago

From what I gather, PackageResult would need (perhaps in a child class PackageUpgradeResult?) to carry the information whether the package is up-to-date. The code path

if (availablePackage.Version > installedPackage.Version || config.Force)
{
    if (availablePackage.Version > installedPackage.Version)
    {

could then be extended accordingly, and the last argument here:

if (config.RegularOuptut)
{
    this.Log().Warn(() => @"{0}There are {1} packages available for upgrade.{0} See the log for details.".format_with(
        Environment.NewLine,
        noopUpgrades.Count));
}

would need to be changed to, e.g. noopUpgrades.Count(u => u.VersionState == VersionState.NewerVersionAvailable).

ferventcoder commented 9 years ago

Perhaps. I did extend it a bit:

Chocolatey can upgrade 10/127 package(s). 
 2 package(s) had warnings.
 See the log for details.
Warnings:
  - binroot
  - ruby