Skip to content
Merged
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Pkg v1.12 Release Notes
The functions `Pkg.status`, `Pkg.why`, `Pkg.instantiate`, `Pkg.precompile` (and their REPL variants) have been updated
to take a `workspace` option. Read more about this feature in the manual about the TOML-files.
- `status` now shows when different versions/sources of dependencies are loaded than that which is expected by the manifest ([#4109])
- It is now possible to specify "sources" for packages in a `[sources]` section in Project.toml.
This can be used to add non-registered normal or test dependencies. Packages are also automatically added to `[sources]` when they are added by url or devved.

Pkg v1.11 Release Notes
=======================
Expand All @@ -22,7 +24,7 @@ Pkg v1.10 Release Notes
=======================

Pkg v1.9 Release Notes
=======================
======================

- New functionality: `Pkg.why` and `pkg> why` to show why a package is inside the environment (shows all "paths" to a package starting at the direct dependencies).
- When code coverage tracking is enabled for `Pkg.test` the new path-specific code-coverage option is used to limit coverage
Expand Down
30 changes: 21 additions & 9 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,26 @@ end
function update_source_if_set(project, pkg)
source = get(project.sources, pkg.name, nothing)
source === nothing && return
# This should probably not modify the dicts directly...
if pkg.repo.source !== nothing
source["url"] = pkg.repo.source
end
if pkg.repo.rev !== nothing
source["rev"] = pkg.repo.rev
end
if pkg.path !== nothing
source["path"] = pkg.path
if pkg.repo == GitRepo()
delete!(project.sources, pkg.name)
else
# This should probably not modify the dicts directly...
if pkg.repo.source !== nothing
source["url"] = pkg.repo.source
delete!(source, "path")
end
if pkg.repo.rev !== nothing
source["rev"] = pkg.repo.rev
delete!(source, "path")
end
if pkg.repo.subdir !== nothing
source["subdir"] = pkg.repo.subdir
end
if pkg.path !== nothing
source["path"] = pkg.path
delete!(source, "url")
delete!(source, "rev")
end
end
if pkg.subdir !== nothing
source["subdir"] = pkg.subdir
Expand Down Expand Up @@ -427,6 +438,7 @@ function pin(ctx::Context, pkgs::Vector{PackageSpec}; all_pkgs::Bool=false, kwar
pkgerror("pinning a package requires a single version, not a versionrange")
end
end
update_source_if_set(ctx.env.project, pkg)
end

project_deps_resolve!(ctx.env, pkgs)
Expand Down
8 changes: 8 additions & 0 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,14 @@ function write_env(env::EnvCache; update_undo=true,
@assert entry.repo.subdir == repo.subdir
end
end
if entry.path !== nothing
env.project.sources[pkg] = Dict("path" => entry.path)
elseif entry.repo != GitRepo()
d = Dict("url" => entry.repo.source)
entry.repo.rev !== nothing && (d["rev"] = entry.repo.rev)
entry.repo.subdir !== nothing && (d["subdir"] = entry.repo.subdir)
env.project.sources[pkg] = d
end
end

if (env.project != env.original_project) && (!skip_writing_project)
Expand Down
22 changes: 12 additions & 10 deletions test/new.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3248,16 +3248,18 @@ temp_pkg_dir() do project_path
end
end
@testset "test resolve with tree hash" begin
mktempdir() do dir
path = copy_test_package(dir, "ResolveWithRev")
cd(path) do
with_current_env() do
@test !isfile("Manifest.toml")
@test !isdir(joinpath(DEPOT_PATH[1], "packages", "Example"))
Pkg.resolve()
@test isdir(joinpath(DEPOT_PATH[1], "packages", "Example"))
rm(joinpath(DEPOT_PATH[1], "packages", "Example"); recursive = true)
Pkg.resolve()
isolate() do
mktempdir() do dir
path = copy_test_package(dir, "ResolveWithRev")
cd(path) do
with_current_env() do
@test !isfile("Manifest.toml")
@test !isdir(joinpath(DEPOT_PATH[1], "packages", "Example"))
Pkg.resolve()
@test isdir(joinpath(DEPOT_PATH[1], "packages", "Example"))
rm(joinpath(DEPOT_PATH[1], "packages", "Example"); recursive=true)
Pkg.resolve()
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/sources.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ temp_pkg_dir() do project_path
cp("Project.toml.bak", "Project.toml"; force=true)
cp("BadManifest.toml", "Manifest.toml"; force=true)
Pkg.resolve()
@test Pkg.project().sources["Example"] == Dict("url" => "https://github.com/JuliaLang/Example.jl")
@test Pkg.project().sources["Example"] == Dict("rev" => "master", "url" => "https://github.com/JuliaLang/Example.jl")
@test Pkg.project().sources["LocalPkg"] == Dict("path" => "LocalPkg")
end
end
Expand Down