Monorepo management for opam overlays
0
fork

Configure Feed

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

Add opam-repo cloning to monopam pull

When running `monopam pull`, if the opam-repo directory doesn't exist
locally, look up the current user's opamrepo URL from the opamverse
registry and clone it automatically.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+39 -5
+17 -1
bin/main.ml
··· 106 106 merges" ); 107 107 `I ("2.", "Adds or pulls the git subtree into the monorepo"); 108 108 `P 109 + "If the opam-repo doesn't exist locally, it will be cloned from the \ 110 + URL registered for your account in the opamverse registry."; 111 + `P 109 112 "If a specific package is given, only that package's repository is \ 110 113 processed."; 111 114 `P "The operation will fail if any checkout has uncommitted changes."; ··· 117 120 with_config env @@ fun config -> 118 121 let fs = Eio.Stdenv.fs env in 119 122 let proc = Eio.Stdenv.process_mgr env in 120 - match Monopam.pull ~proc ~fs ~config ?package () with 123 + (* Look up opam-repo URL from registry using verse config *) 124 + let opam_repo_url = 125 + match Monopam.Verse_config.load ~fs () with 126 + | Error _ -> None 127 + | Ok verse_config -> 128 + let handle = Monopam.Verse_config.handle verse_config in 129 + match Monopam.Verse_registry.clone_or_pull ~proc ~fs ~config:verse_config () with 130 + | Error _ -> None 131 + | Ok registry -> 132 + match Monopam.Verse_registry.find_member registry ~handle with 133 + | None -> None 134 + | Some member -> Some member.opamrepo 135 + in 136 + match Monopam.pull ~proc ~fs ~config ?package ?opam_repo_url () with 121 137 | Ok () -> 122 138 Fmt.pr "Pull completed.@."; 123 139 `Ok ()
+15 -2
lib/monopam.ml
··· 606 606 | Ok ab -> ab.behind 607 607 | Error _ -> 0 608 608 609 - let pull ~proc ~fs ~config ?package () = 609 + let pull ~proc ~fs ~config ?package ?opam_repo_url () = 610 610 let fs_t = fs_typed fs in 611 - (* Update the opam repo first *) 611 + (* Update the opam repo first - clone if needed *) 612 612 let opam_repo = Config.Paths.opam_repo config in 613 613 if Git.is_repo ~proc ~fs:fs_t opam_repo then begin 614 614 Log.info (fun m -> m "Updating opam repo at %a" Fpath.pp opam_repo); ··· 621 621 | Ok () -> () 622 622 | Error e -> 623 623 Log.warn (fun m -> m "Failed to update opam repo: %a" Git.pp_error e) 624 + end 625 + else begin 626 + (* Opam repo doesn't exist - clone it if we have a URL *) 627 + match opam_repo_url with 628 + | Some url -> 629 + Log.info (fun m -> m "Cloning opam repo from %s to %a" url Fpath.pp opam_repo); 630 + let url = Uri.of_string url in 631 + let branch = Config.default_branch config in 632 + (match Git.clone ~proc ~fs:fs_t ~url ~branch opam_repo with 633 + | Ok () -> Log.info (fun m -> m "Opam repo cloned successfully") 634 + | Error e -> Log.warn (fun m -> m "Failed to clone opam repo: %a" Git.pp_error e)) 635 + | None -> 636 + Log.info (fun m -> m "Opam repo at %a does not exist and no URL provided" Fpath.pp opam_repo) 624 637 end; 625 638 (* Ensure directories exist before computing status *) 626 639 ensure_checkouts_dir ~fs:fs_t ~config;
+7 -2
lib/monopam.mli
··· 69 69 fs:Eio.Fs.dir_ty Eio.Path.t -> 70 70 config:Config.t -> 71 71 ?package:string -> 72 + ?opam_repo_url:string -> 72 73 unit -> 73 74 (unit, error) result 74 - (** [pull ~proc ~fs ~config ?package ()] pulls updates from remotes. 75 + (** [pull ~proc ~fs ~config ?package ?opam_repo_url ()] pulls updates from remotes. 75 76 76 77 For each package (or the specified package): 1. Clones or fetches the 77 78 individual checkout 2. Adds or pulls the subtree in the monorepo 78 79 80 + If the opam-repo doesn't exist locally and [opam_repo_url] is provided, 81 + clones it from that URL first. 82 + 79 83 Aborts if any checkout or the monorepo has uncommitted changes. 80 84 81 85 @param proc Eio process manager 82 86 @param fs Eio filesystem 83 87 @param config Monopam configuration 84 - @param package Optional specific package to pull *) 88 + @param package Optional specific package to pull 89 + @param opam_repo_url Optional URL to clone opam-repo from if it doesn't exist *) 85 90 86 91 (** {2 Push} *) 87 92