diff --git a/src/API.jl b/src/API.jl index f584e558f7..2375d85851 100644 --- a/src/API.jl +++ b/src/API.jl @@ -194,47 +194,26 @@ for f in (:develop, :add, :rm, :up, :pin, :free, :test, :build, :status, :why, : end end + function update_source_if_set(env, pkg) project = env.project source = get(project.sources, pkg.name, nothing) if source !== nothing - 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 + # This should probably not modify the dicts directly... + if pkg.repo.source !== nothing + source["url"] = pkg.repo.source end - if pkg.subdir !== nothing - source["subdir"] = pkg.subdir + if pkg.repo.rev !== nothing + source["rev"] = pkg.repo.rev + end + if pkg.path !== nothing + source["path"] = pkg.path end + path, repo = get_path_repo(project, env.project_file, env.manifest_file, pkg.name) if path !== nothing pkg.path = path end - if repo.source !== nothing - pkg.repo.source = repo.source - end - if repo.rev !== nothing - pkg.repo.rev = repo.rev - end - if repo.subdir !== nothing - pkg.repo.subdir = repo.subdir - end end # Packages in manifest should have their paths set to the path in the manifest diff --git a/src/Types.jl b/src/Types.jl index e2edde47bf..60f411ec42 100644 --- a/src/Types.jl +++ b/src/Types.jl @@ -1299,19 +1299,6 @@ function write_env( @assert entry.repo.subdir == repo.subdir end end - if entry !== nothing - if entry.path !== nothing - # Convert path from manifest-relative to project-relative before writing - project_relative_path = manifest_path_to_project_path(env.project_file, env.manifest_file, entry.path) - env.project.sources[pkg] = Dict("path" => project_relative_path) - elseif entry.repo != GitRepo() - d = Dict{String, String}() - entry.repo.source !== nothing && (d["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 end if (env.project != env.original_project) && (!skip_writing_project) write_project(env) diff --git a/test/sources.jl b/test/sources.jl index 4d6010ffa6..c28dca21fe 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("rev" => "master", "url" => "https://github.com/JuliaLang/Example.jl") + @test Pkg.project().sources["Example"] == Dict("url" => "https://github.com/JuliaLang/Example.jl") @test Pkg.project().sources["LocalPkg"] == Dict("path" => "LocalPkg") end end @@ -49,6 +49,18 @@ temp_pkg_dir() do project_path Pkg.test() end end + + @testset "Don't add paths or URLs to sources in v1.12" begin + # Test that we're not creating sources when dev-ing + Pkg.generate("A") + Pkg.generate("B") + Pkg.activate("A") + Pkg.develop(path = "B") + @test isempty(Pkg.project().sources) + + Pkg.add(url = "https://github.com/JuliaLang/Example.jl", rev = "master") + @test isempty(Pkg.project().sources) + end end end end