Skip to content

Commit

Permalink
feature(pkg): Single repo source (ocaml#8950)
Browse files Browse the repository at this point in the history
* feature(pkg): Single repo source

Signed-off-by: Marek Kubica <marek@tarides.com>
  • Loading branch information
Leonidas-from-XIV committed Oct 27, 2023
1 parent ec2ee12 commit dd8b9d6
Show file tree
Hide file tree
Showing 23 changed files with 676 additions and 288 deletions.
34 changes: 6 additions & 28 deletions bin/pkg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -316,19 +316,9 @@ module Lock = struct
| Some path, None ->
let repo_id = Repository_id.of_path path in
Fiber.return @@ [ Opam_repo.of_opam_repo_dir_path ~source:None ~repo_id path ]
| None, Some url ->
let repo = Fetch.Opam_repository.of_url url in
let+ opam_repository = Fetch.Opam_repository.path repo in
(match opam_repository with
| Ok { path; repo_id } ->
[ Opam_repo.of_opam_repo_dir_path
~source:(Some (OpamUrl.to_string url))
~repo_id
path
]
| Error _ ->
User_error.raise
[ Pp.text "Can't determine the location of the opam-repository" ])
| None, Some (url : OpamUrl.t) ->
let+ opam_repo = Opam_repo.of_git_repo ~repo_id:None ~source:url.path in
[ opam_repo ]
| None, None ->
repositories
|> Fiber.parallel_map ~f:(fun name ->
Expand All @@ -341,19 +331,7 @@ module Lock = struct
]
| Some repo ->
let url = Dune_pkg.Pkg_workspace.Repository.opam_url repo in
let repo = Fetch.Opam_repository.of_workspace_repo repo in
let+ opam_repository = Fetch.Opam_repository.path repo in
(match opam_repository with
| Ok { path; repo_id } ->
Opam_repo.of_opam_repo_dir_path
~source:(Some (OpamUrl.to_string url))
~repo_id
path
| Error _ ->
User_error.raise
[ Pp.textf "Can't determine the location of the opam-repository '%s'"
@@ Dune_pkg.Pkg_workspace.Repository.Name.to_string name
]))
Opam_repo.of_git_repo ~repo_id:None ~source:url.path)
;;

let find_local_packages =
Expand Down Expand Up @@ -581,15 +559,15 @@ module Outdated = struct
; repositories
}
->
let+ repos =
let* repos =
Lock.get_repos
repos
~opam_repository_path
~opam_repository_url
~repositories
and+ local_packages = Lock.find_local_packages in
let lock_dir = Lock_dir.read_disk lock_dir_path in
let results =
let+ results =
Dune_pkg_outdated.find ~repos ~local_packages lock_dir.packages
in
( Dune_pkg_outdated.pp ~transitive ~lock_dir_path results
Expand Down
2 changes: 1 addition & 1 deletion boot/libs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ let local_libraries =
false, None)
; ("src/fs", Some "Fs", false, None)
; ("src/dune_findlib", Some "Dune_findlib", false, None)
; ("src/dune_vcs", Some "Dune_vcs", false, None)
; ("vendor/sha", None, false, None)
; ("vendor/uutf", None, false, None)
; ("vendor/opam/src/core", None, false, None)
Expand All @@ -77,7 +78,6 @@ let local_libraries =
; ("src/install", Some "Install", false, None)
; ("otherlibs/dune-site/src/private", Some "Dune_site_private", false,
None)
; ("src/dune_vcs", Some "Dune_vcs", false, None)
; ("src/dune_threaded_console", Some "Dune_threaded_console", false, None)
; ("vendor/lwd/lwd", None, false, None)
; ("vendor/notty/src", None, true, None)
Expand Down
1 change: 1 addition & 0 deletions src/dune_pkg/dune
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
dune_lang
dune_console
dune_re
dune_vcs
opam_core
opam_repository
opam_format
Expand Down
10 changes: 10 additions & 0 deletions src/dune_pkg/file_entry.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
open Stdune

type source =
| Path of Path.t
| Content of string

type t =
{ original : source
; local_file : Path.Local.t
}
10 changes: 10 additions & 0 deletions src/dune_pkg/file_entry.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
open Stdune

type source =
| Path of Path.t
| Content of string

type t =
{ original : source
; local_file : Path.Local.t
}
16 changes: 4 additions & 12 deletions src/dune_pkg/lock_dir.ml
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,6 @@ module Write_disk = struct

type t = unit -> unit

module Files_entry = struct
type t =
{ original_file : Path.t
; local_file : Path.Local.t
}
end

let prepare ~lock_dir_path ~files lock_dir =
let lock_dir_path = Path.source lock_dir_path in
let remove_dir_if_exists = safely_remove_lock_dir_if_exists_thunk lock_dir_path in
Expand All @@ -508,13 +501,12 @@ module Write_disk = struct
Path.relative lock_dir_path (Package_name.to_string package_name ^ ".files")
in
Path.mkdir_p files_dir;
List.iter files ~f:(fun { Files_entry.original_file; local_file } ->
List.iter files ~f:(fun { File_entry.original; local_file } ->
let dst = Path.append_local files_dir local_file in
Path.mkdir_p (Path.parent_exn dst);
Io.copy_file
~src:original_file
~dst:(Path.append_local files_dir local_file)
())))
match original with
| Path src -> Io.copy_file ~src ~dst ()
| Content content -> Io.write_file dst content)))
;;

let commit t = t ()
Expand Down
9 changes: 1 addition & 8 deletions src/dune_pkg/lock_dir.mli
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,9 @@ module Write_disk : sig
type lock_dir := t
type t

module Files_entry : sig
type t =
{ original_file : Path.t
; local_file : Path.Local.t
}
end

val prepare
: lock_dir_path:Path.Source.t
-> files:Files_entry.t Package_name.Map.Multi.t
-> files:File_entry.t Package_name.Map.Multi.t
-> lock_dir
-> t

Expand Down
Loading

0 comments on commit dd8b9d6

Please sign in to comment.