Skip to content

Commit

Permalink
Add debugging + remove invalid test
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerWitt committed Jan 14, 2025
1 parent 338069c commit 1194a1a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 54 deletions.
38 changes: 22 additions & 16 deletions hex/helpers/lib/check_update.exs
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,30 @@ end

[dependency_name] = System.argv()

case UpdateChecker.run(dependency_name) do
{:ok, version} ->
version = :erlang.term_to_binary({:ok, version})
IO.write(:stdio, version)
try do
case UpdateChecker.run(dependency_name) do
{:ok, version} ->
version = :erlang.term_to_binary({:ok, version})
IO.write(:stdio, version)

{:error, %Version.InvalidRequirementError{} = error} ->
result = :erlang.term_to_binary({:error, "Invalid requirement: #{error.requirement}"})
IO.write(:stdio, result)
{:error, %Version.InvalidRequirementError{} = error} ->
result = :erlang.term_to_binary({:error, "Invalid requirement: #{error.requirement}"})
IO.write(:stdio, result)

{:error, %Mix.Error{} = error} ->
result = :erlang.term_to_binary({:error, "Dependency resolution failed: #{error.message}"})
IO.write(:stdio, result)
{:error, %Mix.Error{} = error} ->
result = :erlang.term_to_binary({:error, "Dependency resolution failed: #{error.message}"})
IO.write(:stdio, result)

{:error, :dependency_resolution_timed_out} ->
# We do nothing here because Hex is already printing out a message in stdout
nil
{:error, :dependency_resolution_timed_out} ->
# We do nothing here because Hex is already printing out a message in stdout
nil

{:error, error} ->
result = :erlang.term_to_binary({:error, "Unknown error in check_update: #{inspect(error)}"})
IO.write(:stdio, result)
{:error, error} ->
result = :erlang.term_to_binary({:error, "Unknown error in check_update: #{inspect(error)}"})
try do
IO.write(:stdio, result)
rescue e ->
IO.inspect("invalid chars: " <> inspect(error))
end
end
end
4 changes: 3 additions & 1 deletion hex/helpers/mix.lock
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
%{}
%{
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
}
4 changes: 2 additions & 2 deletions hex/spec/dependabot/hex/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@
end

context "with a tag (rather than a ref)" do
let(:mixfile_fixture_name) { "git_source_with_charlist" }
let(:lockfile_fixture_name) { "git_source_with_charlist" }
let(:mixfile_fixture_name) { "git_source_tag_can_update" }
let(:lockfile_fixture_name) { "git_source_tag_can_update" }

it "includes the git dependency" do
expect(dependencies.length).to eq(2)
Expand Down
11 changes: 0 additions & 11 deletions hex/spec/dependabot/hex/update_checker/file_preparer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,6 @@
'ref: "v1.2.1"}'
)
end

context "when there are single quotes" do
let(:mixfile_fixture_name) { "git_source_with_charlist" }

it "updates the pin" do
expect(prepared_mixfile.content).to include(
'{:phoenix, ">= 0", github: "dependabot-fixtures/phoenix", ' \
"ref: 'v1.2.1'}"
)
end
end
end
end

Expand Down
24 changes: 0 additions & 24 deletions hex/spec/fixtures/mixfiles/git_source_with_charlist

This file was deleted.

0 comments on commit 1194a1a

Please sign in to comment.