diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f39463873..1aaac21ee3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ======================= @@ -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 diff --git a/src/API.jl b/src/API.jl index 834fbdcef5..70a59334e3 100644 --- a/src/API.jl +++ b/src/API.jl @@ -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 @@ -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) diff --git a/src/Types.jl b/src/Types.jl index 5f72f49c96..96f951434f 100644 --- a/src/Types.jl +++ b/src/Types.jl @@ -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) diff --git a/test/new.jl b/test/new.jl index 4f68bca11d..8b4f4c3bc1 100644 --- a/test/new.jl +++ b/test/new.jl @@ -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 diff --git a/test/sources.jl b/test/sources.jl index 35425aea21..aeb42313e0 100644 --- a/test/sources.jl +++ b/test/sources.jl @@ -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