Skip to content

Commit

Permalink
Allow use of a url and subdir in [sources]
Browse files Browse the repository at this point in the history
Monorepos exist, so we shouldn't complain when somebody tries to combine
the url and subdir parameters.
  • Loading branch information
tecosaur committed Dec 2, 2024
1 parent cd75456 commit 3c0e098
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ function update_source_if_set(project, pkg)
if pkg.path !== nothing
source["path"] = pkg.path
end
if pkg.subdir !== nothing
source["subdir"] = pkg.subdir
end
path, repo = get_path_repo(project, pkg.name)
if path !== nothing
pkg.path = path
Expand All @@ -205,6 +208,9 @@ function update_source_if_set(project, pkg)
if repo.rev !== nothing
pkg.repo.rev = repo.rev
end
if repo.subdir !== nothing
pkg.repo.subdir = repo.subdir
end
end

function develop(ctx::Context, pkgs::Vector{PackageSpec}; shared::Bool=true,
Expand Down
2 changes: 1 addition & 1 deletion src/project.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ read_project_compat(raw, project::Project) =

read_project_sources(::Nothing, project::Project) = Dict{String,Any}()
function read_project_sources(raw::Dict{String,Any}, project::Project)
valid_keys = ("path", "url", "rev")
valid_keys = ("path", "url", "rev", "subdir")
sources = Dict{String,Any}()
for (name, source) in raw
if !(source isa AbstractDict)
Expand Down
6 changes: 6 additions & 0 deletions test/sources.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ temp_pkg_dir() do project_path
end
end

cd(joinpath(dir, "WithSources", "TestMonorepo")) do
with_current_env() do
Pkg.test()
end
end

cd(joinpath(dir, "WithSources", "TestProject")) do
with_current_env() do
Pkg.test()
Expand Down
13 changes: 13 additions & 0 deletions test/test_packages/WithSources/TestMonorepo/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name = "TestMonorepo"
uuid = "864d8eef-2526-4817-933e-34008eadd182"
authors = ["KristofferC <[email protected]>"]
version = "0.1.0"

[extras]
Example = "d359f271-ef68-451f-b4fc-6b43e571086c"

[sources]
Example = {url = "https://github.com/JuliaLang/Pkg.jl", subdir = "test/test_packages/Example"}

[targets]
test = ["Example"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module TestMonorepo

greet() = print("Hello World!")

end
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
using Example

0 comments on commit 3c0e098

Please sign in to comment.