Skip to content

Improved error message for version restrictions #633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Switch to releases, and more information for empty releases
  • Loading branch information
beta-ziliani committed Nov 4, 2024
commit 8d56a6a30658b1750ed25c85e7da87eac693f021
23 changes: 15 additions & 8 deletions src/commands/command.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down