From fec9002b7eaf206d402a1be7f0fee70ef4559ac5 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Thu, 22 May 2025 18:06:33 -0400 Subject: [PATCH 1/4] `Pkg.Registry.update()`: throw if an error is encountered --- src/Registry/Registry.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Registry/Registry.jl b/src/Registry/Registry.jl index 32e9364050..df22c58559 100644 --- a/src/Registry/Registry.jl +++ b/src/Registry/Registry.jl @@ -392,7 +392,7 @@ function update(; name=nothing, uuid=nothing, url=nothing, path=nothing, linked= update([RegistrySpec(; name, uuid, url, path, linked)]; kwargs...) end end -function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, depots = [depots1()], update_cooldown = Second(1)) +function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, depots = [depots1()], update_cooldown = Second(1), throw_on_error = true) registry_update_log = get_registry_update_log() for depot in depots depot_regs = isempty(regs) ? reachable_registries(; depots=depot) : regs @@ -430,6 +430,7 @@ function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, try download_verify(url, nothing, tmp) catch err + throw_on_error && rethrow() push!(errors, (reg.path, "failed to download from $(url). Exception: $(sprint(showerror, err))")) @goto done_tarball_read end From e003a4b01bfb4f5bcbf5ada8c76b3f9628ca9159 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Thu, 22 May 2025 18:26:09 -0400 Subject: [PATCH 2/4] Fix some more locations --- src/Registry/Registry.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Registry/Registry.jl b/src/Registry/Registry.jl index df22c58559..e1370721cb 100644 --- a/src/Registry/Registry.jl +++ b/src/Registry/Registry.jl @@ -469,6 +469,7 @@ function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, download_verify_unpack(url, nothing, tmp, ignore_existence = true, io=io) registry_update_log[string(reg.uuid)] = now() catch err + throw_on_error && rethrow() push!(errors, (reg.path, "failed to download and unpack from $(url). Exception: $(sprint(showerror, err))")) @goto done_tarball_unpack end @@ -511,6 +512,7 @@ function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, GitTools.fetch(io, repo; refspecs=["+refs/heads/$branch:refs/remotes/origin/$branch"]) catch e e isa Pkg.Types.PkgError || rethrow() + throw_on_error && rethrow() push!(errors, (reg.path, "failed to fetch from repo: $(e.msg)")) @goto done_git end @@ -526,6 +528,7 @@ function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, sleep(1) @goto merge elseif e isa LibGit2.GitError && e.code == LibGit2.Error.ENOTFOUND + throw_on_error && rethrow() push!(errors, (reg.path, "branch origin/$branch not found")) @goto done_git else @@ -538,6 +541,7 @@ function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, try LibGit2.rebase!(repo, "origin/$branch") catch e e isa LibGit2.GitError || rethrow() + throw_on_error && rethrow() push!(errors, (reg.path, "registry failed to rebase on origin/$branch")) @goto done_git end From d430c1a8dd01280a7c90ab0d4dac8451e03945d8 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Fri, 23 May 2025 13:17:12 -0400 Subject: [PATCH 3/4] Set `throw_on_error = false` by default --- src/Registry/Registry.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Registry/Registry.jl b/src/Registry/Registry.jl index e1370721cb..901db8fcbb 100644 --- a/src/Registry/Registry.jl +++ b/src/Registry/Registry.jl @@ -392,7 +392,7 @@ function update(; name=nothing, uuid=nothing, url=nothing, path=nothing, linked= update([RegistrySpec(; name, uuid, url, path, linked)]; kwargs...) end end -function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, depots = [depots1()], update_cooldown = Second(1), throw_on_error = true) +function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, depots = [depots1()], update_cooldown = Second(1), throw_on_error = false) registry_update_log = get_registry_update_log() for depot in depots depot_regs = isempty(regs) ? reachable_registries(; depots=depot) : regs From 918f84bff4b2aad867c6ef043442b97ebece43ae Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Fri, 23 May 2025 13:20:54 -0400 Subject: [PATCH 4/4] Wait until the end to throw --- src/Registry/Registry.jl | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Registry/Registry.jl b/src/Registry/Registry.jl index 901db8fcbb..d817d350c1 100644 --- a/src/Registry/Registry.jl +++ b/src/Registry/Registry.jl @@ -430,7 +430,6 @@ function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, try download_verify(url, nothing, tmp) catch err - throw_on_error && rethrow() push!(errors, (reg.path, "failed to download from $(url). Exception: $(sprint(showerror, err))")) @goto done_tarball_read end @@ -469,7 +468,6 @@ function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, download_verify_unpack(url, nothing, tmp, ignore_existence = true, io=io) registry_update_log[string(reg.uuid)] = now() catch err - throw_on_error && rethrow() push!(errors, (reg.path, "failed to download and unpack from $(url). Exception: $(sprint(showerror, err))")) @goto done_tarball_unpack end @@ -512,7 +510,6 @@ function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, GitTools.fetch(io, repo; refspecs=["+refs/heads/$branch:refs/remotes/origin/$branch"]) catch e e isa Pkg.Types.PkgError || rethrow() - throw_on_error && rethrow() push!(errors, (reg.path, "failed to fetch from repo: $(e.msg)")) @goto done_git end @@ -528,7 +525,6 @@ function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, sleep(1) @goto merge elseif e isa LibGit2.GitError && e.code == LibGit2.Error.ENOTFOUND - throw_on_error && rethrow() push!(errors, (reg.path, "branch origin/$branch not found")) @goto done_git else @@ -541,7 +537,6 @@ function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, try LibGit2.rebase!(repo, "origin/$branch") catch e e isa LibGit2.GitError || rethrow() - throw_on_error && rethrow() push!(errors, (reg.path, "registry failed to rebase on origin/$branch")) @goto done_git end @@ -559,6 +554,9 @@ function update(regs::Vector{RegistrySpec}; io::IO=stderr_f(), force::Bool=true, warn_str *= "\n — $reg — $err" end @error warn_str + if throw_on_error + Pkg.Types.pkgerror(warn_str) + end end end # mkpidlock end