Skip to content

Commit

Permalink
Fix command outdated for dep with no releases (crystal-lang#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Dec 21, 2020
1 parent d2070c0 commit bd1938b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions spec/integration/outdated_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ describe "outdated" do
end
end

it "no releases" do
commit = git_commits("missing").first
with_shard({dependencies: {missing: "*"}}, {missing: "0.1.0+git.commit.#{commit}"}) do
run "shards install"

stdout = run "shards outdated --no-color"
# FIXME: This should actually report dependencies are up to date (#446)
stdout.should contain("W: Outdated dependencies:")
stdout.should contain(" * missing (installed: 0.1.0 at #{commit[0..6]})")
end
end

it "available version matching pessimistic operator" do
with_shard({dependencies: {orm: "~> 0.3.0"}}, {orm: "0.3.1"}) do
run "shards install"
Expand Down
5 changes: 3 additions & 2 deletions src/commands/outdated.cr
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ module Shards
else
Versions.without_prereleases(resolver.available_releases)
end
latest = Versions.sort(available_versions).first
latest = Versions.sort(available_versions).first?

return if latest == installed

@up_to_date = false
Expand All @@ -66,7 +67,7 @@ module Shards
end

# also report latest version:
if Versions.compare(latest, package.version) < 0
if latest && Versions.compare(latest, package.version) < 0
@output << ", latest: " << resolver.report_version(latest)
end

Expand Down

0 comments on commit bd1938b

Please sign in to comment.