Monorepo management for opam overlays
1(** Add a package to the monorepo.
2
3 Looks up the package in the opam repo, ensures its checkout exists, and
4 pulls the subtree into the monorepo. *)
5
6let src = Logs.Src.create "monopam.add" ~doc:"Monopam add operation"
7
8module Log = (val Logs.src_log src : Logs.LOG)
9
10let run ~sw ~proc ~fs ~config ~package:pkg_name () =
11 let fs_t = Ctx.fs_typed fs in
12 Ctx.ensure_checkouts_dir ~fs:fs_t ~config;
13 match Init.ensure ~sw ~proc ~fs:fs_t ~config with
14 | Error e -> Error e
15 | Ok () -> (
16 match Ctx.package ~fs:(fs_t :> _ Eio.Path.t) ~config pkg_name with
17 | Error e -> Error e
18 | Ok pkg -> (
19 Log.info (fun m -> m "Adding package %s" (Package.name pkg));
20 match Ctx.ensure_checkout ~proc ~fs:fs_t ~config pkg with
21 | Error e -> Error (Ctx.Git_error e)
22 | Ok () ->
23 Pull.subtree ~sw ~proc ~fs ~config pkg |> Result.map (fun _ -> ())
24 ))