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

add ranked suggestions to add error #2985

Merged
merged 5 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
pass ctx through
  • Loading branch information
IanButterworth committed Feb 14, 2022
commit 81ad18bc0ea44e632d7363aabdfcc5fdcc5500ed
14 changes: 7 additions & 7 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function add(ctx::Context, pkgs::Vector{PackageSpec}; preserve::PreserveLevel=PR
project_deps_resolve!(ctx.env, pkgs)
registry_resolve!(ctx.registries, pkgs)
stdlib_resolve!(pkgs)
ensure_resolved(ctx.env.manifest, pkgs, registry=true)
ensure_resolved(ctx, ctx.env.manifest, pkgs, registry=true)

for pkg in pkgs
if Types.collides_with_project(ctx.env, pkg)
Expand Down Expand Up @@ -298,7 +298,7 @@ function rm(ctx::Context, pkgs::Vector{PackageSpec}; mode=PKGMODE_PROJECT, all_p

mode == PKGMODE_PROJECT && project_deps_resolve!(ctx.env, pkgs)
mode == PKGMODE_MANIFEST && manifest_resolve!(ctx.env.manifest, pkgs)
ensure_resolved(ctx.env.manifest, pkgs)
ensure_resolved(ctx, ctx.env.manifest, pkgs)

Operations.rm(ctx, pkgs; mode)
return
Expand Down Expand Up @@ -336,7 +336,7 @@ function up(ctx::Context, pkgs::Vector{PackageSpec};
mode == PKGMODE_MANIFEST && manifest_resolve!(ctx.env.manifest, pkgs)
project_deps_resolve!(ctx.env, pkgs)
manifest_resolve!(ctx.env.manifest, pkgs)
ensure_resolved(ctx.env.manifest, pkgs)
ensure_resolved(ctx, ctx.env.manifest, pkgs)
end
Operations.up(ctx, pkgs, level; skip_writing_project)
return
Expand Down Expand Up @@ -375,7 +375,7 @@ function pin(ctx::Context, pkgs::Vector{PackageSpec}; all_pkgs::Bool=false, kwar
end

project_deps_resolve!(ctx.env, pkgs)
ensure_resolved(ctx.env.manifest, pkgs)
ensure_resolved(ctx, ctx.env.manifest, pkgs)
Operations.pin(ctx, pkgs)
return
end
Expand All @@ -401,7 +401,7 @@ function free(ctx::Context, pkgs::Vector{PackageSpec}; all_pkgs::Bool=false, kwa
end

manifest_resolve!(ctx.env.manifest, pkgs)
ensure_resolved(ctx.env.manifest, pkgs)
ensure_resolved(ctx, ctx.env.manifest, pkgs)

Operations.free(ctx, pkgs; err_if_free = !all_pkgs)
return
Expand All @@ -426,7 +426,7 @@ function test(ctx::Context, pkgs::Vector{PackageSpec};
project_resolve!(ctx.env, pkgs)
project_deps_resolve!(ctx.env, pkgs)
manifest_resolve!(ctx.env.manifest, pkgs)
ensure_resolved(ctx.env.manifest, pkgs)
ensure_resolved(ctx, ctx.env.manifest, pkgs)
end
Operations.test(
ctx,
Expand Down Expand Up @@ -1020,7 +1020,7 @@ function build(ctx::Context, pkgs::Vector{PackageSpec}; verbose=false, kwargs...
end
project_resolve!(ctx.env, pkgs)
manifest_resolve!(ctx.env.manifest, pkgs)
ensure_resolved(ctx.env.manifest, pkgs)
ensure_resolved(ctx, ctx.env.manifest, pkgs)
Operations.build(ctx, Set{UUID}(pkg.uuid for pkg in pkgs), verbose)
end

Expand Down
10 changes: 6 additions & 4 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ function build_versions(ctx::Context, uuids::Set{UUID}; verbose=false)
build_project_preferences = Base.get_preferences()
end
else
build_project_override = gen_target_project(ctx.env, ctx.registries, pkg, source_path, "build")
build_project_override = gen_target_project(ctx, pkg, source_path, "build")
with_load_path([projectfile_path(source_path)]) do
build_project_preferences = Base.get_preferences()
end
Expand Down Expand Up @@ -1617,7 +1617,9 @@ function parse_REQUIRE(require_path::String)
end

# "targets" based test deps -> "test/Project.toml" based deps
function gen_target_project(env::EnvCache, registries::Vector{Registry.RegistryInstance}, pkg::PackageSpec, source_path::String, target::String)
function gen_target_project(ctx::Context, pkg::PackageSpec, source_path::String, target::String)
env = ctx.env
registries = ctx.registries
test_project = Types.Project()
if projectfile_path(source_path; strict=true) === nothing
# no project file, assuming this is an old REQUIRE package
Expand All @@ -1630,7 +1632,7 @@ function gen_target_project(env::EnvCache, registries::Vector{Registry.RegistryI
package_specs = [PackageSpec(name=pkg) for pkg in test_pkgs]
registry_resolve!(registries, package_specs)
stdlib_resolve!(package_specs)
ensure_resolved(env.manifest, package_specs, registry=true)
ensure_resolved(ctx, env.manifest, package_specs, registry=true)
for spec in package_specs
test_project.deps[spec.name] = spec.uuid
end
Expand Down Expand Up @@ -1710,7 +1712,7 @@ function test(ctx::Context, pkgs::Vector{PackageSpec};
test_project_preferences = Base.get_preferences()
end
else
test_project_override = gen_target_project(ctx.env, ctx.registries, pkg, source_path, "test")
test_project_override = gen_target_project(ctx, pkg, source_path, "test")
with_load_path(projectfile_path(source_path)) do
test_project_preferences = Base.get_preferences()
end
Expand Down
5 changes: 2 additions & 3 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ function set_repo_source_from_registry!(ctx, pkg)
Pkg.Operations.update_registries(ctx; force=false)
registry_resolve!(ctx.registries, pkg)
end
ensure_resolved(ctx.env.manifest, [pkg]; registry=true)
ensure_resolved(ctx, ctx.env.manifest, [pkg]; registry=true)
# We might have been given a name / uuid combo that does not have an entry in the registry
for reg in ctx.registries
regpkg = get(reg, pkg.uuid, nothing)
Expand Down Expand Up @@ -885,7 +885,7 @@ function stdlib_resolve!(pkgs::AbstractVector{PackageSpec})
end

# Ensure that all packages are fully resolved
function ensure_resolved(manifest::Manifest,
function ensure_resolved(ctx::Context, manifest::Manifest,
pkgs::AbstractVector{PackageSpec};
registry::Bool=false,)::Nothing
unresolved_uuids = Dict{String,Vector{UUID}}()
Expand All @@ -901,7 +901,6 @@ function ensure_resolved(manifest::Manifest,
push!(unresolved_names, pkg.uuid)
end
isempty(unresolved_uuids) && isempty(unresolved_names) && return
ctx = Context()
msg = sprint(context = ctx.io) do io
if !isempty(unresolved_uuids)
print(io, "The following package names could not be resolved:")
Expand Down