Skip to content

Commit

Permalink
Add debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmj committed May 31, 2024
1 parent c561e70 commit 5e528f0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/hex/http.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ defmodule Hex.HTTP do

@impl :mix_hex_http
def request(method, url, headers, body, opts \\ []) do
if Mix.debug?() do
Hex.Shell.debug("Hex.HTTP.request(#{inspect(method)}, #{inspect(url)}, ...)")
end

headers =
headers
|> build_headers()
Expand Down
8 changes: 6 additions & 2 deletions lib/hex/registry/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ defmodule Hex.Registry.Server do
|> Enum.reject(&(&1 in state.fetched))
|> Enum.reject(&(&1 in state.pending))

purge_repo_from_cache(packages, state)
purge_changed_repos_from_cache(packages, state)

if Hex.State.fetch!(:offline) do
prefetch_offline(packages, state)
Expand Down Expand Up @@ -271,7 +271,7 @@ defmodule Hex.Registry.Server do
:ok = :ets.tab2file(tid, String.to_charlist(path))
end

defp purge_repo_from_cache(packages, %{ets: ets}) do
defp purge_changed_repos_from_cache(packages, %{ets: ets}) do
Enum.each(packages, fn {repo, _package} ->
repo = repo || "hexpm"
config = Hex.Repo.get_repo(repo)
Expand Down Expand Up @@ -409,6 +409,10 @@ defmodule Hex.Registry.Server do
"Failed to fetch record for #{Hex.Utils.package_name(repo, package)} from registry#{cached_message}"
)

if Mix.debug?() do
Hex.Shell.error("Error result: #{inspect(result)}")
end

if missing_status?(result) do
Hex.Shell.error(
"This could be because the package does not exist, it was spelled " <>
Expand Down
7 changes: 5 additions & 2 deletions lib/hex/scm.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ defmodule Hex.SCM do
true
end

def format(_opts) do
"Hex package"
def format(opts) do
case opts[:repo] do
"hexpm" -> "Hex package"
repo -> "Hex package (from #{repo})"
end
end

def format_lock(opts) do
Expand Down

0 comments on commit 5e528f0

Please sign in to comment.