@@ -4,22 +4,38 @@ type extra_files =
44 | Inside_files_dir of Path .t option
55 | Git_files of Path.Local .t option * Rev_store.At_rev .t
66
7- type nonrec t =
7+ type rest =
88 { opam_file : OpamFile.OPAM .t
99 ; package : OpamPackage .t
1010 ; extra_files : extra_files
1111 ; loc : Loc .t
1212 ; dune_build : bool
1313 }
1414
15- let dune_build t = t.dune_build
16- let loc t = t.loc
17- let package t = t.package
18- let opam_file t = t.opam_file
15+ type nonrec t =
16+ | Dune
17+ | Rest of rest
18+
19+ let dune = Dune
20+
21+ let dune_build = function
22+ | Dune -> false
23+ | Rest t -> t.dune_build
24+ ;;
25+
26+ let loc = function
27+ | Dune -> Loc. none
28+ | Rest t -> t.loc
29+ ;;
1930
20- let set_url t url =
21- let opam_file = OpamFile.OPAM. with_url (OpamFile.URL. create url) t.opam_file in
22- { t with opam_file }
31+ let package = function
32+ | Dune -> Dune_dep. package
33+ | Rest t -> t.package
34+ ;;
35+
36+ let opam_file = function
37+ | Dune -> Dune_dep. opam_file
38+ | Rest t -> t.opam_file
2339;;
2440
2541let add_opam_package_to_opam_file package opam_file =
@@ -28,37 +44,44 @@ let add_opam_package_to_opam_file package opam_file =
2844 |> OpamFile.OPAM. with_name (OpamPackage. name package)
2945;;
3046
31- let read_opam_file package ~opam_file_path ~opam_file_contents =
32- Opam_file. read_from_string_exn ~contents: opam_file_contents opam_file_path
33- |> add_opam_package_to_opam_file package
47+ let read_opam_file package ~opam_file_path ~opam_file_contents ~url =
48+ let opam_file =
49+ Opam_file. read_from_string_exn ~contents: opam_file_contents opam_file_path
50+ |> add_opam_package_to_opam_file package
51+ in
52+ match url with
53+ | None -> opam_file
54+ | Some url -> OpamFile.OPAM. with_url (OpamFile.URL. create url) opam_file
3455;;
3556
36- let git_repo package ~opam_file ~opam_file_contents rev ~files_dir =
57+ let git_repo package ~opam_file ~opam_file_contents rev ~files_dir ~ url =
3758 let opam_file_path = Path. of_local opam_file in
38- let opam_file = read_opam_file package ~opam_file_path ~opam_file_contents in
59+ let opam_file = read_opam_file package ~opam_file_path ~opam_file_contents ~url in
3960 let loc = Loc. in_file opam_file_path in
40- { dune_build = false
41- ; loc
42- ; package
43- ; opam_file
44- ; extra_files = Git_files (files_dir, rev)
45- }
61+ Rest
62+ { dune_build = false
63+ ; loc
64+ ; package
65+ ; opam_file
66+ ; extra_files = Git_files (files_dir, rev)
67+ }
4668;;
4769
48- let local_fs package ~dir ~opam_file_path ~files_dir =
70+ let local_fs package ~dir ~opam_file_path ~files_dir ~ url =
4971 let opam_file_path = Path. append_local dir opam_file_path in
5072 let files_dir = Option. map files_dir ~f: (Path. append_local dir) in
5173 let opam_file =
5274 let opam_file_contents = Io. read_file ~binary: true opam_file_path in
53- read_opam_file package ~opam_file_path ~opam_file_contents
75+ read_opam_file package ~opam_file_path ~opam_file_contents ~url
5476 in
5577 let loc = Loc. in_file opam_file_path in
56- { dune_build = false
57- ; loc
58- ; package
59- ; extra_files = Inside_files_dir files_dir
60- ; opam_file
61- }
78+ Rest
79+ { dune_build = false
80+ ; loc
81+ ; package
82+ ; extra_files = Inside_files_dir files_dir
83+ ; opam_file
84+ }
6285;;
6386
6487(* Scan a path recursively down retrieving a list of all files together with their
@@ -92,18 +115,26 @@ let local_package ~command_source loc opam_file opam_package =
92115 in
93116 let opam_file = add_opam_package_to_opam_file opam_package opam_file in
94117 let package = OpamFile.OPAM. package opam_file in
95- { dune_build; opam_file; package; loc; extra_files = Inside_files_dir None }
118+ Rest { dune_build; opam_file; package; loc; extra_files = Inside_files_dir None }
96119;;
97120
98121open Fiber.O
99122
100123let get_opam_package_files resolved_packages =
101124 let indexed = List. mapi resolved_packages ~f: (fun i w -> i, w) |> Int.Map. of_list_exn in
102125 let from_dirs, from_git =
103- Int.Map. partition_map indexed ~f: (fun (resolved_package : t ) ->
104- match resolved_package.extra_files with
105- | Git_files (files_dir , rev ) -> Right (files_dir, rev)
106- | Inside_files_dir dir -> Left dir)
126+ let _dune, without_dune =
127+ Int.Map. partition_map indexed ~f: (function
128+ | Dune -> Left ()
129+ | Rest t -> Right t)
130+ in
131+ let dirs, git =
132+ Int.Map. partition_map without_dune ~f: (fun (resolved_package : rest ) ->
133+ match resolved_package.extra_files with
134+ | Git_files (files_dir , rev ) -> Right (files_dir, rev)
135+ | Inside_files_dir dir -> Left dir)
136+ in
137+ dirs, git
107138 in
108139 let + from_git =
109140 if Int.Map. is_empty from_git
0 commit comments