summaryrefslogtreecommitdiff
path: root/lib/chef/provider/package/chocolatey.rb
diff options
context:
space:
mode:
authorJon Cowie <jcowie@chef.io>2017-09-22 14:27:36 +0100
committerJon Cowie <jcowie@chef.io>2017-09-22 14:27:36 +0100
commitd9a27abe8f6efccc1b6ef73e1e56bdec24e5a010 (patch)
tree52eee10ba7af042e17726b40102bfd59fa90db34 /lib/chef/provider/package/chocolatey.rb
parenta5597127294b65df79dc1b98cefe845e4e36de2b (diff)
downloadchef-d9a27abe8f6efccc1b6ef73e1e56bdec24e5a010.tar.gz
Cater for Windows package managers using the version string "latest"
Some windows package managers use the version string "latest" - when this happens, have version_compare always return 0, as we can't reliably tell what version number we're looking at. Signed-off-by: Jon Cowie <jcowie@chef.io>
Diffstat (limited to 'lib/chef/provider/package/chocolatey.rb')
-rw-r--r--lib/chef/provider/package/chocolatey.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/chef/provider/package/chocolatey.rb b/lib/chef/provider/package/chocolatey.rb
index a1ec4504a0..c832116377 100644
--- a/lib/chef/provider/package/chocolatey.rb
+++ b/lib/chef/provider/package/chocolatey.rb
@@ -141,6 +141,17 @@ EOS
private
+ def version_compare(v1, v2)
+ if v1 == "latest" || v2 == "latest"
+ return 0
+ end
+
+ gem_v1 = Gem::Version.new(v1)
+ gem_v2 = Gem::Version.new(v2)
+
+ gem_v1 <=> gem_v2
+ end
+
# Magic to find where chocolatey is installed in the system, and to
# return the full path of choco.exe
#