Skip to content

Commit

Permalink
only complete fixed packages for pkg> free
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Oct 21, 2023
1 parent b39ba05 commit 72cd1da
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/REPLMode/command_declarations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ PSA[:name => "free",
PSA[:name => "all", :api => :all_pkgs => true],
],
:arg_parser => parse_package,
:completions => complete_installed_packages,
:completions => complete_fixed_packages,
:description => "undoes a `pin`, `develop`, or stops tracking a repo",
:help => md"""
free pkg[=uuid] ...
Expand Down
9 changes: 9 additions & 0 deletions src/REPLMode/completions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ function complete_installed_packages_and_compat(options, partial)
end
end

function complete_fixed_packages(options, partial)
env = try EnvCache()
catch err
err isa PkgError || rethrow()
return String[]
end
return unique!([entry.name for (uuid, entry) in env.manifest.deps if Operations.isfixed(entry)])
end

function complete_add_dev(options, partial, i1, i2)
comps, idx, _ = complete_local_dir(partial, i1, i2)
if occursin(Base.Filesystem.path_separator_re, partial)
Expand Down
8 changes: 8 additions & 0 deletions test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ temp_pkg_dir() do project_path; cd(project_path) do
@test isempty(c)
c, r = test_complete("rm --project Exam")
@test isempty(c)
c, r = test_complete("free PackageWithDep")
@test "PackageWithDependency" in c # given this was devved

c, r = test_complete("rm -m PackageWithDep")
@test "PackageWithDependency" in c
Expand Down Expand Up @@ -363,6 +365,12 @@ temp_pkg_dir() do project_path; cd(project_path) do
@test "remove" in c
@test apply_completion("rm E") == "rm Example"
@test apply_completion("add Exampl") == "add Example"
c, r = test_complete("free Exa")
@test isempty(c) # given this was added i.e. not fixed
pkg"pin Example"
c, r = test_complete("free Exa")
@test "Example" in c
pkg"free Example"

# help mode
@test apply_completion("?ad") == "?add"
Expand Down

0 comments on commit 72cd1da

Please sign in to comment.