Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only complete fixed packages for pkg> free #3674

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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