Skip to content

Commit

Permalink
Drop build info from julia version stored in manifest (#2995)
Browse files Browse the repository at this point in the history
(cherry picked from commit 487fdd1)
  • Loading branch information
IanButterworth authored and KristofferC committed May 24, 2022
1 parent 1531663 commit 70fa7f1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
10 changes: 6 additions & 4 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -287,22 +287,24 @@ function collect_fixed!(env::EnvCache, pkgs::Vector{PackageSpec}, names::Dict{UU
return fixed
end

# drops build detail in version but keeps the main prerelease context
# i.e. dropbuild(v"2.0.1-rc1.21321") == v"2.0.1-rc1"
dropbuild(v::VersionNumber) = VersionNumber(v.major, v.minor, v.patch, isempty(v.prerelease) ? () : (v.prerelease[1],))

# Resolve a set of versions given package version specs
# looks at uuid, version, repo/path,
# sets version to a VersionNumber
# adds any other packages which may be in the dependency graph
# all versioned packges should have a `tree_hash`
# all versioned packages should have a `tree_hash`
function resolve_versions!(env::EnvCache, registries::Vector{Registry.RegistryInstance}, pkgs::Vector{PackageSpec}, julia_version)
# compatibility
if julia_version !== nothing
env.manifest.julia_version = julia_version
# only set the manifest julia_version if ctx.julia_version is not nothing
env.manifest.julia_version = dropbuild(VERSION)
v = intersect(julia_version, get_compat(env.project, "julia"))
if isempty(v)
@warn "julia version requirement for project not satisfied" _module=nothing _file=nothing
end
else
env.manifest.julia_version = VERSION
end
names = Dict{UUID, String}(uuid => name for (uuid, (name, version)) in stdlibs())
# recursive search for packages which are tracking a path
Expand Down
2 changes: 1 addition & 1 deletion test/manifest/formats/v2.0/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.7.0-DEV.1199"
julia_version = "1.7.0-DEV"
manifest_format = "2.0"
some_other_field = "other"
some_other_data = [1,2,3,4]
Expand Down
2 changes: 1 addition & 1 deletion test/manifest/formats/v3.0_unknown/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.7.0-DEV.1199"
julia_version = "1.7.0-DEV"
manifest_format = "3.0" # NOT ACTUALLY v3.0 format. Just here to test a warning!

[[deps.Logging]]
Expand Down
18 changes: 12 additions & 6 deletions test/manifests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,27 @@ end

@testset "Manifest metadata" begin
@testset "julia_version" begin
@testset "new environment: value is `nothing`, then `VERSION` after resolve" begin
@testset "dropbuild" begin
@test Pkg.Operations.dropbuild(v"1.2.3-DEV.2134") == v"1.2.3-DEV"
@test Pkg.Operations.dropbuild(v"1.2.3-DEV") == v"1.2.3-DEV"
@test Pkg.Operations.dropbuild(v"1.2.3") == v"1.2.3"
@test Pkg.Operations.dropbuild(v"1.2.3-rc1") == v"1.2.3-rc1"
end
@testset "new environment: value is `nothing`, then ~`VERSION` after resolve" begin
isolate(loaded_depot=true) do
Pkg.activate(; temp=true)
@test Pkg.Types.Context().env.manifest.julia_version == nothing
Pkg.add("Profile")
@test Pkg.Types.Context().env.manifest.julia_version == VERSION
@test Pkg.Types.Context().env.manifest.julia_version == Pkg.Operations.dropbuild(VERSION)
end
end
@testset "activating old environment: maintains old version, then `VERSION` after resolve" begin
@testset "activating old environment: maintains old version, then ~`VERSION` after resolve" begin
reference_manifest_isolated_test("v2.0") do env_dir, env_manifest
Pkg.activate(env_dir)
@test Pkg.Types.Context().env.manifest.julia_version == v"1.7.0-DEV.1199"
@test Pkg.Types.Context().env.manifest.julia_version == v"1.7.0-DEV"

Pkg.add("Profile")
@test Pkg.Types.Context().env.manifest.julia_version == VERSION
@test Pkg.Types.Context().env.manifest.julia_version == Pkg.Operations.dropbuild(VERSION)
end
end
@testset "instantiate manifest from different julia_version" begin
Expand All @@ -170,7 +176,7 @@ end
reference_manifest_isolated_test("v2.0") do env_dir, env_manifest
Pkg.activate(env_dir)
@test_logs (:warn, r"The active manifest file") Pkg.instantiate()
@test Pkg.Types.Context().env.manifest.julia_version == v"1.7.0-DEV.1199"
@test Pkg.Types.Context().env.manifest.julia_version == v"1.7.0-DEV"
end
end
end
Expand Down

0 comments on commit 70fa7f1

Please sign in to comment.