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
2 changes: 1 addition & 1 deletion src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ function collect_project(pkg::Union{PackageSpec, Nothing}, path::String)
end

is_tracking_path(pkg) = pkg.path !== nothing
is_tracking_repo(pkg) = pkg.repo.source !== nothing
is_tracking_repo(pkg) = (pkg.repo.source !== nothing || pkg.repo.rev !== nothing)
is_tracking_registry(pkg) = !is_tracking_path(pkg) && !is_tracking_repo(pkg)
isfixed(pkg) = !is_tracking_registry(pkg) || pkg.pinned

Expand Down
4 changes: 2 additions & 2 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,6 @@ function write_env(env::EnvCache; update_undo=true,
@assert entry.path == path
end
if repo != GitRepo()
@assert entry.repo.source == repo.source
if repo.rev !== nothing
@assert entry.repo.rev == repo.rev
end
Expand All @@ -1266,7 +1265,8 @@ function write_env(env::EnvCache; update_undo=true,
if entry.path !== nothing
env.project.sources[pkg] = Dict("path" => entry.path)
elseif entry.repo != GitRepo()
d = Dict("url" => entry.repo.source)
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
Expand Down
21 changes: 19 additions & 2 deletions test/new.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1358,14 +1358,14 @@ end
@test length(args) == 1
@test args[1].path == normpath("C:\\\\Users\\\\test\\\\project")
@test args[1].subdir === nothing

# Test with forward slashes too
api, args, opts = first(Pkg.pkg"add C:/Users/test/project")
@test api == Pkg.add
@test length(args) == 1
@test args[1].path == normpath("C:/Users/test/project")
@test args[1].subdir === nothing

# Test that actual subdir syntax still works with Windows paths
api, args, opts = first(Pkg.pkg"add C:\\Users\\test\\project:subdir")
@test api == Pkg.add
Expand Down Expand Up @@ -3516,6 +3516,23 @@ end
end
end

@testset "test instantiate with sources with only rev" begin
isolate() do
mktempdir() do dir
cp(joinpath(@__DIR__, "test_packages", "sources_only_rev", "Project.toml"), joinpath(dir, "Project.toml"))
cd(dir) do
with_current_env() do
@test !isfile("Manifest.toml")
Pkg.instantiate()
uuid, info = only(Pkg.dependencies())
@test info.git_revision == "ba3d6704f09330ae973773496a4212f85e0ffe45"
@test info.git_source == "https://github.com/JuliaLang/Example.jl.git"
end
end
end
end
end

@testset "status showing incompatible loaded deps" begin
cmd = addenv(`$(Base.julia_cmd()) --color=no --startup-file=no -e "
using Pkg
Expand Down
5 changes: 5 additions & 0 deletions test/test_packages/sources_only_rev/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
Example = "7876af07-990d-54b4-ab0e-23690620f79a"

[sources]
Example = {rev = "ba3d6704f09330ae973773496a4212f85e0ffe45"}