Skip to content

Commit

Permalink
Merge pull request #403 from samoht/speed-up-pull
Browse files Browse the repository at this point in the history
Do not load the switch state to get the current OCaml version
  • Loading branch information
Leonidas-from-XIV authored Mar 19, 2024
2 parents ad8f896 + 805d547 commit 141d351
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
- Fix support for pinned packages. In that case, it is not necessary to add
dev-repo conflicts as `opam-monorepo` will always use the pinned repository.
(#398, #353, @samoht, @reynir, reported by @emillon)
- Improve the speed of `opam monorepo pull`. Loading an switch state might take
a few seconds -- replace it with a call to `ocamlc --version` to check if the
lockfile is compatible with the currently available OCaml compiler
(#403, @samoht)

### Removed

Expand Down
9 changes: 4 additions & 5 deletions cli/pull.ml
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,15 @@ let run (`Yes yes) (`Root root) (`Lockfile explicit_lockfile)
D.Lockfile.ocaml_version lockfile
|> Base.Result.of_option ~error:(`Msg "OCaml compiler not in lockfile")
in
OpamSwitchState.with_ `Lock_none global_state @@ fun switch_state ->
let switch_ocaml_version =
OpamSwitchState.get_package switch_state D.Config.compiler_package_name
|> OpamPackage.version
in
let* pulled =
D.Pull.duniverse ~global_state ~root ~full
~preserve_symlinks:keep_symlinked_dir ~trim_clone:(not keep_git_dir)
duniverse
in
let* switch_ocaml_version =
let+ version = D.Exec.ocaml_version () in
OpamPackage.Version.of_string (Ocaml_version.to_string version)
in
(match
D.Opam.version_is_at_least locked_ocaml_version switch_ocaml_version
with
Expand Down

0 comments on commit 141d351

Please sign in to comment.