Skip to content
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
41 changes: 10 additions & 31 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 13 additions & 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("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
Expand Down Expand Up @@ -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
Expand Down
Loading