(** Add a package to the monorepo. Looks up the package in the opam repo, ensures its checkout exists, and pulls the subtree into the monorepo. *) let src = Logs.Src.create "monopam.add" ~doc:"Monopam add operation" module Log = (val Logs.src_log src : Logs.LOG) let run ~sw ~proc ~fs ~config ~package:pkg_name () = let fs_t = Ctx.fs_typed fs in Ctx.ensure_checkouts_dir ~fs:fs_t ~config; match Init.ensure ~sw ~proc ~fs:fs_t ~config with | Error e -> Error e | Ok () -> ( match Ctx.package ~fs:(fs_t :> _ Eio.Path.t) ~config pkg_name with | Error e -> Error e | Ok pkg -> ( Log.info (fun m -> m "Adding package %s" (Package.name pkg)); match Ctx.ensure_checkout ~proc ~fs:fs_t ~config pkg with | Error e -> Error (Ctx.Git_error e) | Ok () -> Pull.subtree ~sw ~proc ~fs ~config pkg |> Result.map (fun _ -> ()) ))