From 56a1d564aeb5832dec2d58176252aa91fd2e8b73 Mon Sep 17 00:00:00 2001 From: Watson Date: Mon, 16 Sep 2013 22:38:18 +0900 Subject: [PATCH] fix a bug in `motion update' where comparing version will do unexpected behavior using the string "2.9" > "2.10" #=> true So, when we released version 2.10, Prompting message to update that may not be appeared. --- lib/motion/project/command/update.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/motion/project/command/update.rb b/lib/motion/project/command/update.rb index 8e317ea8..cad15c82 100644 --- a/lib/motion/project/command/update.rb +++ b/lib/motion/project/command/update.rb @@ -36,6 +36,12 @@ module Motion; module Project resp end + def latest_version?(product, latest) + product = product.split(".") + latest = latest.split(".") + (product[0].to_i >= latest[0].to_i) && (product[1].to_i >= latest[1].to_i) + end + def run(args) check_mode = false wanted_software_version = nil @@ -66,7 +72,7 @@ module Motion; module Project latest_version, message = File.read(update_check_file).split('|', 2) message ||= '' - if latest_version > product_version + unless latest_version?(product_version, latest_version) message = "A new version of RubyMotion is available. Run `sudo motion update' to upgrade.\n" + message end message.strip!