Monorepo management for opam overlays
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

monopam: simplify backward-compatible aliases

Simplify the backward-compatible exports in monopam.ml:
- Remove unnecessary ~proc:_ ignored parameters
- Use direct module aliases instead of wrapper functions
- Clean up redundant type definitions
- Remove unused functions (discover_packages_from_monorepo, package, etc.)
- Fix cmd_diff unused variable warning
- Update bin commands to use simplified API

+69 -171
+2 -2
bin/cmd_clean.ml
··· 38 38 Common.with_config env @@ fun config -> 39 39 let fs = Eio.Stdenv.fs env in 40 40 let proc = Eio.Stdenv.process_mgr env in 41 - match Monopam.clean ~proc ~fs ~config ~dry_run ~force () with 41 + match Monopam.Clean.clean ~proc ~fs ~config ~dry_run ~force () with 42 42 | Ok () -> `Ok () 43 43 | Error e -> 44 - Fmt.epr "Error: %a@." Monopam.pp_error_with_hint e; 44 + Fmt.epr "Error: %a@." Monopam.Ctx.pp_error_with_hint e; 45 45 `Error (false, "clean failed") 46 46 in 47 47 Cmd.v info
+1 -2
bin/cmd_diff.ml
··· 31 31 Eio_main.run @@ fun env -> 32 32 Common.with_config env @@ fun config -> 33 33 let fs = Eio.Stdenv.fs env in 34 - let proc = Eio.Stdenv.process_mgr env in 35 - match Monopam.status ~proc ~fs ~config () with 34 + match Monopam.status ~fs ~config () with 36 35 | Error e -> 37 36 Fmt.epr "Error: %a@." Monopam.pp_error_with_hint e; 38 37 `Error (false, "diff failed")
+2 -2
bin/cmd_fetch.ml
··· 33 33 let fs = Eio.Stdenv.fs env in 34 34 let proc = Eio.Stdenv.process_mgr env in 35 35 (* Get status to find packages *) 36 - match Monopam.status ~proc ~fs ~config () with 36 + match Monopam.Ctx.status ~fs ~config () with 37 37 | Error e -> 38 - Fmt.epr "Error: %a@." Monopam.pp_error_with_hint e; 38 + Fmt.epr "Error: %a@." Monopam.Ctx.pp_error_with_hint e; 39 39 `Error (false, "fetch failed") 40 40 | Ok statuses -> 41 41 let statuses =
+2 -2
bin/cmd_pull.ml
··· 37 37 Common.with_config env @@ fun config -> 38 38 let fs = Eio.Stdenv.fs env in 39 39 let proc = Eio.Stdenv.process_mgr env in 40 - match Monopam.pull ~proc ~fs ~config ~packages () with 40 + match Monopam.Pull.pull ~proc ~fs ~config ~packages () with 41 41 | Ok () -> 42 42 let elapsed = Unix.gettimeofday () -. t0 in 43 43 Fmt.pr "@.%a Monorepo updated in %a.@." Tty.Span.pp ··· 48 48 (Fmt.str "%.1fs" elapsed)); 49 49 `Ok () 50 50 | Error e -> 51 - Fmt.epr "Error: %a@." Monopam.pp_error_with_hint e; 51 + Fmt.epr "Error: %a@." Monopam.Ctx.pp_error_with_hint e; 52 52 `Error (false, "pull failed") 53 53 in 54 54 Cmd.v info Term.(ret (const run $ Common.packages_arg $ Common.logging_term))
+3 -3
bin/cmd_push.ml
··· 64 64 let fs = Eio.Stdenv.fs env in 65 65 let proc = Eio.Stdenv.process_mgr env in 66 66 match 67 - Monopam.push ~proc ~fs ~config ~packages ~upstream:(not local_only) ~clean 68 - ~force () 67 + Monopam.Push.push ~proc ~fs ~config ~packages ~upstream:(not local_only) 68 + ~clean ~force () 69 69 with 70 70 | Ok () -> 71 71 let elapsed = Unix.gettimeofday () -. t0 in ··· 85 85 (Fmt.str "%.1fs" elapsed)); 86 86 `Ok () 87 87 | Error e -> 88 - Fmt.epr "Error: %a@." Monopam.pp_error_with_hint e; 88 + Fmt.epr "Error: %a@." Monopam.Ctx.pp_error_with_hint e; 89 89 `Error (false, "push failed") 90 90 in 91 91 Cmd.v info
+2 -2
bin/cmd_split.ml
··· 32 32 | Ok result -> 33 33 Fmt.pr "%a@." Monopam.pp_opam_sync_result result; 34 34 `Ok () 35 - | Error e -> 36 - Fmt.epr "Error: %a@." Monopam.pp_error_with_hint e; 35 + | Error (`Config_error e) -> 36 + Fmt.epr "Error: %s@." e; 37 37 `Error (false, "split failed") 38 38 in 39 39 Cmd.v info Term.(ret (const run $ Common.packages_arg $ Common.logging_term))
+1 -1
bin/cmd_status.ml
··· 89 89 Common.with_config env @@ fun config -> 90 90 let fs = Eio.Stdenv.fs env in 91 91 let proc = Eio.Stdenv.process_mgr env in 92 - match Monopam.status ~proc ~fs ~config () with 92 + match Monopam.status ~fs ~config () with 93 93 | Ok statuses -> 94 94 let sources = load_sources ~fs ~config in 95 95 let pp =
+8
lib/ctx.ml
··· 317 317 with Eio.Io _ -> []) 318 318 repos 319 319 320 + (** {1 Status} *) 321 + 322 + let status ~fs ~config () = 323 + let fs = fs_typed fs in 324 + ensure_checkouts_dir ~fs ~config; 325 + discover_packages ~fs:(fs :> _ Eio.Path.t) ~config () 326 + |> Result.map (Status.compute_all ~fs ~config) 327 + 320 328 (** {1 Timing} *) 321 329 322 330 let time_phase name f =
+15 -49
lib/monopam.ml
··· 39 39 module Clean = Clean 40 40 module Diff = Diff 41 41 42 - (** {1 Backward-Compatible Exports} *) 43 - 44 - type error = Ctx.error = 45 - | Config_error of string 46 - | Repo_error of Opam_repo.error 47 - | Git_error of Git_cli.error 48 - | Dirty_state of Package.t list 49 - | Monorepo_dirty 50 - | Package_not_found of string 51 - | Claude_error of string 42 + (** {1 Aliases for bin commands} *) 52 43 53 - let pp_error = Ctx.pp_error 44 + (* Ctx aliases *) 54 45 let pp_error_with_hint = Ctx.pp_error_with_hint 55 - let error_hint = Ctx.error_hint 46 + let discover_packages = Ctx.discover_packages 47 + let unregistered_opam_files = Ctx.unregistered_opam_files 48 + let status = Ctx.status 56 49 57 - type opam_sync_result = Opam_sync.t 58 - type monorepo_package = Monorepo_pkg.t 59 - type pull_result = Pull.result 60 - type diff_entry = Diff.entry 61 - type diff_result = Diff.result 62 - type commit_info = Diff.commit_info 50 + (* Diff aliases *) 63 51 type handle_pull_result = Diff.handle_pull_result 52 + type commit_info = Diff.commit_info 64 53 type cherrypick_result = Diff.cherrypick_result 65 54 66 - let status ~proc:_ ~fs ~config () = 67 - let fs = Ctx.fs_typed fs in 68 - Ctx.ensure_checkouts_dir ~fs ~config; 69 - Ctx.discover_packages ~fs:(fs :> _ Eio.Path.t) ~config () 70 - |> Result.map (Status.compute_all ~fs ~config) 71 - 72 - let pull = Pull.pull 73 - let push = Push.push 74 - let add = Add.add 75 - let remove ~proc:_ = Remove.remove 76 - let clean = Clean.clean 77 - let pp_opam_sync_result = Opam_sync.pp 78 - 79 - let sync_opam_files ~fs ~config ?(packages = []) () = 80 - match Opam_sync.run ~fs:(Ctx.fs_typed fs) ~config ~packages () with 81 - | Ok result -> Ok result 82 - | Error (`Config_error e) -> Error (Config_error e) 83 - 84 - let discover_packages_from_monorepo ~fs ~config ?sources () = 85 - match Monorepo_pkg.discover ~fs:(Ctx.fs_typed fs) ~config ?sources () with 86 - | Ok result -> Ok result 87 - | Error (`Config_error e) -> Error (Config_error e) 88 - 89 - let discover_packages = Ctx.discover_packages 90 - let package = Ctx.package 91 - let unregistered_opam_files = Ctx.unregistered_opam_files 92 - let pp_diff_entry = Diff.pp_entry 93 - let pp_diff_result = Diff.pp 94 55 let pp_handle_pull_result = Diff.pp_handle_pull_result 95 56 let pp_cherrypick_result = Diff.pp_cherrypick_result 96 - let is_commit_sha = Diff.is_commit_sha 97 - let diff = Diff.diff 98 - let diff_show_commit = Diff.show_commit 57 + let pp_diff_result = Diff.pp 99 58 let pull_from_handle = Diff.pull_from_handle 59 + let diff_show_commit = Diff.show_commit 60 + let diff = Diff.diff 61 + let is_commit_sha = Diff.is_commit_sha 100 62 let cherrypick = Diff.cherrypick 63 + 64 + (* Opam_sync aliases *) 65 + let sync_opam_files = Opam_sync.run 66 + let pp_opam_sync_result = Opam_sync.pp
+33 -108
lib/monopam.mli
··· 61 61 module Clean = Clean 62 62 module Diff = Diff 63 63 64 - (** {1 Backward-Compatible Exports} *) 65 - 66 - type error = Ctx.error = 67 - | Config_error of string 68 - | Repo_error of Opam_repo.error 69 - | Git_error of Git_cli.error 70 - | Dirty_state of Package.t list 71 - | Monorepo_dirty 72 - | Package_not_found of string 73 - | Claude_error of string 64 + (** {1 Aliases for bin commands} *) 74 65 75 - val pp_error : error Fmt.t 76 - val pp_error_with_hint : error Fmt.t 77 - val error_hint : error -> string option 78 - 79 - type opam_sync_result = Opam_sync.t 80 - type monorepo_package = Monorepo_pkg.t 81 - type pull_result = Pull.result 82 - type diff_entry = Diff.entry 83 - type diff_result = Diff.result 84 - type commit_info = Diff.commit_info 85 - type handle_pull_result = Diff.handle_pull_result 86 - type cherrypick_result = Diff.cherrypick_result 66 + val pp_error_with_hint : Format.formatter -> Ctx.error -> unit 87 67 88 - val status : 89 - proc:_ Eio.Process.mgr -> 68 + val discover_packages : 90 69 fs:Eio.Fs.dir_ty Eio.Path.t -> 91 70 config:Config.t -> 92 71 unit -> 93 - (Status.t list, error) result 72 + (Package.t list, Ctx.error) result 94 73 95 - val pull : 96 - proc:_ Eio.Process.mgr -> 74 + val unregistered_opam_files : 97 75 fs:Eio.Fs.dir_ty Eio.Path.t -> 98 76 config:Config.t -> 99 - ?packages:string list -> 100 - ?opam_repo_url:string -> 101 - unit -> 102 - (unit, error) result 77 + Package.t list -> 78 + (string * string) list 103 79 104 - val push : 105 - proc:_ Eio.Process.mgr -> 80 + val status : 106 81 fs:Eio.Fs.dir_ty Eio.Path.t -> 107 82 config:Config.t -> 108 - ?packages:string list -> 109 - ?upstream:bool -> 110 - ?clean:bool -> 111 - ?force:bool -> 112 83 unit -> 113 - (unit, error) result 84 + (Status.t list, Ctx.error) result 114 85 115 - val add : 116 - proc:_ Eio.Process.mgr -> 117 - fs:Eio.Fs.dir_ty Eio.Path.t -> 118 - config:Config.t -> 119 - package:string -> 120 - unit -> 121 - (unit, error) result 86 + type handle_pull_result = Diff.handle_pull_result 87 + type commit_info = Diff.commit_info 88 + type cherrypick_result = Diff.cherrypick_result 122 89 123 - val remove : 124 - proc:_ Eio.Process.mgr -> 125 - fs:Eio.Fs.dir_ty Eio.Path.t -> 126 - config:Config.t -> 127 - package:string -> 128 - unit -> 129 - (unit, error) result 90 + val pp_handle_pull_result : Format.formatter -> handle_pull_result -> unit 91 + val pp_cherrypick_result : Format.formatter -> cherrypick_result -> unit 92 + val pp_diff_result : show_patch:bool -> Format.formatter -> Diff.result -> unit 130 93 131 - val clean : 132 - proc:_ Eio.Process.mgr -> 133 - fs:Eio.Fs.dir_ty Eio.Path.t -> 134 - config:Config.t -> 135 - dry_run:bool -> 136 - force:bool -> 137 - unit -> 138 - (unit, error) result 139 - 140 - val pp_opam_sync_result : opam_sync_result Fmt.t 141 - 142 - val sync_opam_files : 143 - fs:Eio.Fs.dir_ty Eio.Path.t -> 144 - config:Config.t -> 145 - ?packages:string list -> 146 - unit -> 147 - (opam_sync_result, error) result 148 - 149 - val discover_packages_from_monorepo : 150 - fs:Eio.Fs.dir_ty Eio.Path.t -> 151 - config:Config.t -> 152 - ?sources:Sources_registry.t -> 153 - unit -> 154 - (monorepo_package list, error) result 155 - 156 - val discover_packages : 157 - fs:Eio.Fs.dir_ty Eio.Path.t -> 158 - config:Config.t -> 159 - unit -> 160 - (Package.t list, error) result 161 - 162 - val package : 163 - fs:Eio.Fs.dir_ty Eio.Path.t -> 164 - config:Config.t -> 165 - string -> 166 - (Package.t, error) result 167 - 168 - val unregistered_opam_files : 169 - fs:Eio.Fs.dir_ty Eio.Path.t -> 170 - config:Config.t -> 171 - Package.t list -> 172 - (string * string) list 173 - 174 - val pp_diff_entry : show_patch:bool -> diff_entry Fmt.t 175 - val pp_diff_result : show_patch:bool -> diff_result Fmt.t 176 - val pp_handle_pull_result : handle_pull_result Fmt.t 177 - val pp_cherrypick_result : cherrypick_result Fmt.t 178 - val is_commit_sha : string -> bool 179 - 180 - val diff : 94 + val pull_from_handle : 181 95 proc:_ Eio.Process.mgr -> 182 96 fs:Eio.Fs.dir_ty Eio.Path.t -> 183 97 config:Config.t -> 184 98 verse_config:Verse_config.t -> 99 + handle:string -> 185 100 ?repo:string -> 186 101 ?refresh:bool -> 187 - ?patch:bool -> 188 102 unit -> 189 - diff_result 103 + (handle_pull_result, Ctx.error) result 190 104 191 105 val diff_show_commit : 192 106 proc:_ Eio.Process.mgr -> ··· 198 112 unit -> 199 113 commit_info option 200 114 201 - val pull_from_handle : 115 + val diff : 202 116 proc:_ Eio.Process.mgr -> 203 117 fs:Eio.Fs.dir_ty Eio.Path.t -> 204 118 config:Config.t -> 205 119 verse_config:Verse_config.t -> 206 - handle:string -> 207 120 ?repo:string -> 208 121 ?refresh:bool -> 122 + ?patch:bool -> 209 123 unit -> 210 - (handle_pull_result, error) result 124 + Diff.result 125 + 126 + val is_commit_sha : string -> bool 211 127 212 128 val cherrypick : 213 129 proc:_ Eio.Process.mgr -> ··· 217 133 sha:string -> 218 134 ?refresh:bool -> 219 135 unit -> 220 - (cherrypick_result, error) result 136 + (cherrypick_result, Ctx.error) result 137 + 138 + val sync_opam_files : 139 + fs:Eio.Fs.dir_ty Eio.Path.t -> 140 + config:Config.t -> 141 + ?packages:string list -> 142 + unit -> 143 + (Opam_sync.t, [ `Config_error of string ]) result 144 + 145 + val pp_opam_sync_result : Format.formatter -> Opam_sync.t -> unit