Skip to content

Commit df2476a

Browse files
authored
Merge pull request #2655 from JuliaLang/fe/backports-release-1.7
Backports Pkg 1.7.0
2 parents 81af75b + acc5f90 commit df2476a

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/API.jl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,19 @@ marking them as "orphaned". This method will only remove orphaned objects (pack
445445
versions, artifacts, and scratch spaces) that have been continually un-used for a period
446446
of `collect_delay`; which defaults to seven days.
447447
448+
Garbage collection is only applied to the "user depot", e.g. the first entry in the
449+
depot path. If you want to run `gc` on all depots set `force=true` (this might require
450+
admin privileges depending on the setup).
451+
448452
Use verbose mode (`verbose=true`) for detailed output.
449453
"""
450-
function gc(ctx::Context=Context(); collect_delay::Period=Day(7), verbose=false, kwargs...)
454+
function gc(ctx::Context=Context(); collect_delay::Period=Day(7), verbose=false, force=false, kwargs...)
451455
Context!(ctx; kwargs...)
452456
env = ctx.env
453457

458+
# Only look at user-depot unless force=true
459+
gc_depots = force ? depots() : [depots1()]
460+
454461
# First, we load in our `manifest_usage.toml` files which will tell us when our
455462
# "index files" (`Manifest.toml`, `Artifacts.toml`) were last used. We will combine
456463
# this knowledge across depots, condensing it all down to a single entry per extant
@@ -467,7 +474,7 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(7), verbose=false,
467474
scratch_parents_by_depot = Dict{String, Dict{String, Set{String}}}()
468475

469476
# Load manifest files from all depots
470-
for depot in depots()
477+
for depot in gc_depots
471478
# When a manifest/artifact.toml is installed/used, we log it within the
472479
# `manifest_usage.toml` files within `write_env_usage()` and `bind_artifact!()`
473480
function reduce_usage!(f::Function, usage_filepath)
@@ -728,7 +735,7 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(7), verbose=false,
728735

729736
# Do an initial scan of our depots to get a preliminary `packages_to_delete`.
730737
packages_to_delete = String[]
731-
for depot in depots()
738+
for depot in gc_depots
732739
depot_orphaned_packages = String[]
733740
packagedir = abspath(depot, "packages")
734741
if isdir(packagedir)
@@ -768,7 +775,7 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(7), verbose=false,
768775
repos_to_delete = String[]
769776
spaces_to_delete = String[]
770777

771-
for depot in depots()
778+
for depot in gc_depots
772779
# We track orphaned objects on a per-depot basis, writing out our `orphaned.toml`
773780
# tracking file immediately, only pushing onto the overall `*_to_delete` lists if
774781
# the package has been orphaned for at least a period of `collect_delay`
@@ -914,7 +921,7 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(7), verbose=false,
914921
end
915922

916923
# Prune package paths that are now empty
917-
for depot in depots()
924+
for depot in gc_depots
918925
packagedir = abspath(depot, "packages")
919926
!isdir(packagedir) && continue
920927

@@ -928,7 +935,7 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(7), verbose=false,
928935
end
929936

930937
# Prune scratch space UUID folders that are now empty
931-
for depot in depots()
938+
for depot in gc_depots
932939
scratch_dir = abspath(depot, "scratchspaces")
933940
!isdir(scratch_dir) && continue
934941

@@ -1622,7 +1629,7 @@ function add_snapshot_to_undo(env=nothing)
16221629
UndoState()
16231630
end
16241631
# Is the current state the same as the previous one, do nothing
1625-
if !isempty(state.entries) && env.project == env.original_project && env.manifest == env.original_manifest
1632+
if !isempty(state.entries) && env.project == env.original_project && env.manifest.deps == env.original_manifest.deps
16261633
return
16271634
end
16281635
snapshot = UndoSnapshot(now(), env.project, env.manifest)

src/REPLMode/REPLMode.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,12 +682,16 @@ function try_prompt_pkg_add(pkgs::Vector{Symbol})
682682
printstyled(ctx.io, ""; color=:green)
683683
Base.prompt(stdin, ctx.io, "(y/n)", default = "y")
684684
catch err
685-
if err isa InterruptException
685+
if err isa InterruptException # if ^C is entered
686686
println(ctx.io)
687687
return false
688688
end
689689
rethrow()
690690
end
691+
if isnothing(resp) # if ^D is entered
692+
println(ctx.io)
693+
return false
694+
end
691695
if lowercase(resp) in ["y", "yes"]
692696
API.add(string.(available_pkgs))
693697
if length(available_pkgs) < length(pkgs)

0 commit comments

Comments
 (0)