Skip to content

Commit fb4a9b0

Browse files
author
KristofferC
committed
hash fixes take 2
1 parent b36690a commit fb4a9b0

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/Operations.jl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,6 +1666,15 @@ function prune_deps(iterator, keep::Set{UUID})
16661666
return
16671667
end
16681668

1669+
function record_project_hash(env::EnvCache)
1670+
return env.manifest.other["project_hash"] = Types.workspace_resolve_hash(env)
1671+
end
1672+
1673+
function finalize_resolve!(env::EnvCache)
1674+
Types.sync_sources_from_manifest!(env)
1675+
record_project_hash(env)
1676+
end
1677+
16691678
#########
16701679
# Build #
16711680
#########
@@ -2237,6 +2246,7 @@ function add(
22372246
# if env is a package add compat entries
22382247
add_compat_entries!(ctx, pkgs)
22392248

2249+
finalize_resolve!(ctx.env)
22402250
write_env(ctx.env)
22412251
show_update(ctx.env, ctx.registries; io = ctx.io)
22422252

@@ -2259,11 +2269,13 @@ function add(
22592269
# if env is a package add compat entries
22602270
add_compat_entries!(ctx, pkgs)
22612271

2272+
finalize_resolve!(ctx.env)
22622273
write_env(ctx.env) # write env before building
22632274
show_update(ctx.env, ctx.registries; io = ctx.io)
22642275
build_versions(ctx, union(new_apply, new_git))
22652276
allow_autoprecomp && Pkg._auto_precompile(ctx, pkgs)
22662277
else
2278+
finalize_resolve!(ctx.env)
22672279
write_env(ctx.env)
22682280
names_str = join(names, ", ")
22692281
printpkgstyle(ctx.io, :Added, "$names_str to [$(target)]")
@@ -2288,6 +2300,7 @@ function develop(
22882300
new_apply = download_source(ctx)
22892301
fixups_from_projectfile!(ctx)
22902302
download_artifacts(ctx; platform = platform, julia_version = ctx.julia_version)
2303+
finalize_resolve!(ctx.env)
22912304
write_env(ctx.env) # write env before building
22922305
show_update(ctx.env, ctx.registries; io = ctx.io)
22932306
return build_versions(ctx, union(new_apply, new_git))
@@ -2442,6 +2455,7 @@ function up(
24422455
new_apply = download_source(ctx)
24432456
fixups_from_projectfile!(ctx)
24442457
download_artifacts(ctx, julia_version = ctx.julia_version)
2458+
finalize_resolve!(ctx.env)
24452459
write_env(ctx.env; skip_writing_project) # write env before building
24462460
show_update(ctx.env, ctx.registries; io = ctx.io, hidden_upgrades_info = true)
24472461

@@ -2516,6 +2530,7 @@ function pin(ctx::Context, pkgs::Vector{PackageSpec})
25162530
new = download_source(ctx)
25172531
fixups_from_projectfile!(ctx)
25182532
download_artifacts(ctx; julia_version = ctx.julia_version)
2533+
finalize_resolve!(ctx.env)
25192534
write_env(ctx.env) # write env before building
25202535
show_update(ctx.env, ctx.registries; io = ctx.io)
25212536
return build_versions(ctx, new)
@@ -2566,6 +2581,7 @@ function free(ctx::Context, pkgs::Vector{PackageSpec}; err_if_free = true)
25662581
new = download_source(ctx)
25672582
fixups_from_projectfile!(ctx)
25682583
download_artifacts(ctx)
2584+
finalize_resolve!(ctx.env)
25692585
write_env(ctx.env) # write env before building
25702586
show_update(ctx.env, ctx.registries; io = ctx.io)
25712587
build_versions(ctx, new)
@@ -2655,9 +2671,7 @@ function sandbox_preserve(env::EnvCache, target::PackageSpec, test_project::Stri
26552671
project = read_project(test_project)
26562672
keep = Set([target.uuid])
26572673
union!(keep, values(project.deps))
2658-
# Sync sources and record hash
2659-
Types.sync_sources_from_manifest!(env)
2660-
Types.record_project_hash(env)
2674+
finalize_resolve!(env)
26612675
# prune and return
26622676
return prune_manifest(env.manifest, keep)
26632677
end

src/Types.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,19 +1418,11 @@ function sync_sources_from_manifest!(env::EnvCache)
14181418
return
14191419
end
14201420

1421-
function record_project_hash(env::EnvCache)
1422-
return env.manifest.other["project_hash"] = workspace_resolve_hash(env)
1423-
end
1424-
14251421
function write_env(
14261422
env::EnvCache; update_undo = true,
14271423
skip_writing_project::Bool = false,
14281424
skip_readonly_check::Bool = false
14291425
)
1430-
# Sync sources from manifest and record hash before writing
1431-
sync_sources_from_manifest!(env)
1432-
record_project_hash(env)
1433-
14341426
# Check if the environment is readonly before attempting to write
14351427
if env.project.readonly && !skip_readonly_check
14361428
pkgerror("Cannot modify a readonly environment. The project at $(env.project_file) is marked as readonly.")

0 commit comments

Comments
 (0)