Skip to content

Commit 8403710

Browse files
committed
Show a generic diff command hint in hex.outdated output
Per review feedback on #1137: listing a `mix hex.package diff` command for every outdated package adds significant output. Show a single generic command hint (`mix hex.package diff APP FROM..TO`) instead. https://claude.ai/code/session_0162egDzWnK8wcGhWZxSk2mB
1 parent c57b435 commit 8403710

2 files changed

Lines changed: 8 additions & 18 deletions

File tree

lib/mix/tasks/hex.outdated.ex

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ defmodule Mix.Tasks.Hex.Outdated do
189189
values = versions |> Enum.map(&format_all_row/1) |> maybe_sort_by(opts[:sort])
190190

191191
diff_links = Enum.map(versions, &build_diff_link/1) |> Enum.reject(&is_nil/1)
192-
diff_commands = Enum.map(versions, &build_diff_command/1) |> Enum.reject(&is_nil/1)
193192

194193
if Enum.empty?(values) do
195194
Hex.Shell.info("No hex dependencies")
@@ -199,8 +198,8 @@ defmodule Mix.Tasks.Hex.Outdated do
199198

200199
base_message = "Run `mix hex.outdated APP` to see requirements for a specific dependency."
201200
diff_message = maybe_diff_message(diff_links)
202-
diff_commands_message = maybe_diff_commands_message(diff_commands)
203-
Hex.Shell.info(["\n", base_message, diff_message, diff_commands_message])
201+
diff_command_message = maybe_diff_command_message(diff_links)
202+
Hex.Shell.info(["\n", base_message, diff_message, diff_command_message])
204203

205204
outdated = outdated(versions)
206205
any_updatable? = any_possible_to_update?(outdated)
@@ -332,17 +331,10 @@ defmodule Mix.Tasks.Hex.Outdated do
332331
diff_link(diff_links)
333332
end
334333

335-
defp build_diff_command([package, _dep_only, lock, latest, _requirements]) do
336-
if Version.compare(lock, latest) == :lt do
337-
"mix hex.package diff #{package} #{lock}..#{latest}"
338-
end
339-
end
340-
341-
defp maybe_diff_commands_message([]), do: ""
334+
defp maybe_diff_command_message([]), do: ""
342335

343-
defp maybe_diff_commands_message(diff_commands) do
344-
commands = Enum.map_join(diff_commands, "\n", &(" " <> &1))
345-
"\n\nTo view the diff of a specific update, run:\n" <> commands
336+
defp maybe_diff_command_message(_diff_links) do
337+
"\n\nTo view the diff of a specific update, run `mix hex.package diff APP FROM..TO`."
346338
end
347339

348340
defp diff_link(diff_links) do

test/mix/tasks/hex.outdated_test.exs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ defmodule Mix.Tasks.Hex.OutdatedTest do
668668
end)
669669
end
670670

671-
test "outdated shows diff commands for outdated packages" do
671+
test "outdated shows a generic diff command hint when updates are available" do
672672
Mix.Project.push(OutdatedDeps.MixProject)
673673

674674
in_tmp(fn ->
@@ -683,10 +683,8 @@ defmodule Mix.Tasks.Hex.OutdatedTest do
683683
lines = flush()
684684
output = Enum.map_join(lines, "\n", fn {_, _, [line]} -> line end)
685685

686-
assert output =~ "To view the diff of a specific update, run:"
687-
assert output =~ "mix hex.package diff ex_doc 0.0.1..0.1.0"
688-
assert output =~ "mix hex.package diff foo 0.1.0..0.1.1"
689-
refute output =~ "mix hex.package diff bar"
686+
assert output =~
687+
"To view the diff of a specific update, run `mix hex.package diff APP FROM..TO`."
690688
end)
691689
end
692690

0 commit comments

Comments
 (0)