Skip to content

Commit 5c1e800

Browse files
add error that explains PackageSpec.repo is a private field
1 parent f517489 commit 5c1e800

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/API.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,10 @@ end
15571557

15581558
function handle_package_input!(pkg::PackageSpec)
15591559
if pkg.path !== nothing && pkg.url !== nothing
1560-
pkgerror("`path` and `url` are conflicting specifications")
1560+
pkgerror("Conflicting `path` and `url` in PackageSpec")
1561+
end
1562+
if pkg.repo.source !== nothing || pkg.repo.rev !== nothing || pkg.repo.subdir !== nothing
1563+
pkgerror("`repo` is a private field of PackageSpec and should not be set directly")
15611564
end
15621565
pkg.repo = Types.GitRepo(rev = pkg.rev, source = pkg.url !== nothing ? pkg.url : pkg.path,
15631566
subdir = pkg.subdir)

src/Types.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ mutable struct PackageSpec
9292
uuid::Union{Nothing,UUID}
9393
version::Union{Nothing,VersionTypes,String}
9494
tree_hash::Union{Nothing,SHA1}
95-
repo::GitRepo
95+
repo::GitRepo # private
9696
path::Union{Nothing,String}
9797
pinned::Bool
9898
# used for input only

test/new.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,6 +1831,8 @@ end
18311831
Pkg.dependencies(exuuid) do pkg
18321832
@test pkg.version > v"0.3.0"
18331833
end
1834+
1835+
@test_throws PkgError("`repo` is a private field of PackageSpec and should not be set directly") Pkg.add([PackageSpec(;repo=LibGit2.GitRepo(url="someurl"))])
18341836
end
18351837
end
18361838

@@ -2069,7 +2071,7 @@ end
20692071
end
20702072
end
20712073
end
2072-
end
2074+
end
20732075
end
20742076

20752077
#

0 commit comments

Comments
 (0)