From 8d56a6a30658b1750ed25c85e7da87eac693f021 Mon Sep 17 00:00:00 2001 From: Beta Ziliani Date: Mon, 4 Nov 2024 11:36:11 -0300 Subject: [PATCH] Switch to releases, and more information for empty releases --- src/commands/command.cr | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/commands/command.cr b/src/commands/command.cr index 21d5975b..d1b90adf 100644 --- a/src/commands/command.cr +++ b/src/commands/command.cr @@ -77,17 +77,24 @@ module Shards private def log_available_tags(conflicts) conflicts.join(separator: "\n") do |k, v| req = v.requirement - tags = req.resolver.available_tags.reverse + resolver = req.resolver + releases = resolver.available_releases.map(&.to_s).reverse req = req.requirement - if req.is_a?(Version) || (req.is_a?(VersionReq) && req.patterns.size == 1 && req.patterns[0] !~ /^(<|>|=)/) - req = "v" + req.to_s - found = Levenshtein.find(req, tags, 6) - "For #{k} the closest available tag to #{req} is: #{found}" - elsif tags.empty? - "#{k} doesn't have any tag" + if releases.empty? + tags = resolver.available_tags.reverse!.first(5) + if tags.empty? + info = "And it doesn't have any tags either." + else + info = "For information, these are the latest tags: #{tags.join(", ")}." + end + "#{k} doesn't have any release. #{info} Refer to the shards manual for details." + elsif req.is_a?(Version) || (req.is_a?(VersionReq) && req.patterns.size == 1 && req.patterns[0] !~ /^(<|>|=)/) + req = req.to_s + found = Levenshtein.find(req, releases) + "For #{k} the closest available release to #{req} is: #{found}." else - "For #{k} the last available tags are #{tags.first(5).join(", ")}" + "For #{k} the last available releases are #{releases.first(5).join(", ")}." end end end