···4343 List.fold_left
4444 (fun cfg (name, override) ->
4545 let open Monopam.Verse_config in
4646- Monopam.Config.with_package_override cfg ~name
4747- ?branch:override.branch ?dev_repo:override.dev_repo ())
4646+ Monopam.Config.with_package_override cfg ~name ?branch:override.branch
4747+ ())
4848 base_config
4949 (Monopam.Verse_config.packages verse_config)
5050 in
+7-12
lib/config.ml
···11module Package_config = struct
22- type t = {
33- branch : string option;
44- dev_repo : string option; (** Override dev-repo URL for vendored packages *)
55- }
22+ type t = { branch : string option }
6374 let branch t = t.branch
88- let dev_repo t = t.dev_repo
95106 let codec : t Tomlt.t =
117 Tomlt.(
128 Table.(
1313- obj (fun branch dev_repo -> { branch; dev_repo })
99+ obj (fun branch -> { branch })
1410 |> opt_mem "branch" string ~enc:(fun c -> c.branch)
1515- |> opt_mem "dev_repo" string ~enc:(fun c -> c.dev_repo)
1611 |> finish))
1712end
1813···3631let create ~opam_repo ~checkouts ~monorepo ?(default_branch = "main") () =
3732 { opam_repo; checkouts; monorepo; default_branch; packages = [] }
38333939-let with_package_override t ~name ?branch:branch_opt ?dev_repo:dev_repo_opt () =
3434+let with_package_override t ~name ?branch:branch_opt () =
4035 let existing = List.assoc_opt name t.packages in
4136 let existing_branch = Option.bind existing Package_config.branch in
4242- let existing_dev_repo = Option.bind existing Package_config.dev_repo in
4343- let new_branch = match branch_opt with Some _ -> branch_opt | None -> existing_branch in
4444- let new_dev_repo = match dev_repo_opt with Some _ -> dev_repo_opt | None -> existing_dev_repo in
4545- let pkg_config = Package_config.{ branch = new_branch; dev_repo = new_dev_repo } in
3737+ let new_branch =
3838+ match branch_opt with Some _ -> branch_opt | None -> existing_branch
3939+ in
4040+ let pkg_config = Package_config.{ branch = new_branch } in
4641 let packages = (name, pkg_config) :: List.remove_assoc name t.packages in
4742 { t with packages }
4843
+4-10
lib/config.mli
···14141515 val branch : t -> string option
1616 (** [branch t] returns the branch override for this package, if set. *)
1717-1818- val dev_repo : t -> string option
1919- (** [dev_repo t] returns the dev-repo URL override for this package, if set.
2020- Use this to override the source URL for vendored packages. *)
2117end
22182319type t
···112108 @param monorepo Path to the monorepo
113109 @param default_branch Default branch to track (default: "main") *)
114110115115-val with_package_override :
116116- t -> name:string -> ?branch:string -> ?dev_repo:string -> unit -> t
117117-(** [with_package_override t ~name ?branch ?dev_repo ()] returns a new config
111111+val with_package_override : t -> name:string -> ?branch:string -> unit -> t
112112+(** [with_package_override t ~name ?branch ()] returns a new config
118113 with overrides for the named package.
119114120115 @param branch Override the git branch for this package
121121- @param dev_repo Override the dev-repo URL for vendored packages.
122122- Use this when you've forked someone else's project and want the opam-repo
123123- to point to your fork instead of the original. *)
116116+117117+ Note: For dev-repo URL overrides, use [sources.toml] in the monorepo root. *)
124118125119(** {1 Pretty Printing} *)
126120
+42-40
lib/fork_join.ml
···187187 match push_result with
188188 | Error _ as e -> e
189189 | Ok () ->
190190- (* Update sources.toml with fork entry *)
191191- let sources_path = Fpath.(monorepo / "sources.toml") in
192192- let sources =
193193- match Sources_registry.load ~fs:(fs :> _ Eio.Path.t) sources_path with
194194- | Ok s -> s
195195- | Error _ -> Sources_registry.empty
196196- in
197197- let url = match push_url with
198198- | Some u -> u
199199- | None -> "file://" ^ Fpath.to_string src_path
200200- in
201201- let entry = Sources_registry.{
202202- url;
203203- upstream = None;
204204- branch = Some "main";
205205- reason = Some "Forked from monorepo";
206206- origin = Some Fork;
207207- } in
208208- let sources = Sources_registry.add sources ~subtree:name entry in
209209- (match Sources_registry.save ~fs:(fs :> _ Eio.Path.t) sources_path sources with
210210- | Ok () -> ()
211211- | Error msg -> Logs.warn (fun m -> m "Failed to update sources.toml: %s" msg));
190190+ (* Only update sources.toml if there's a push URL *)
191191+ (match push_url with
192192+ | Some url ->
193193+ let sources_path = Fpath.(monorepo / "sources.toml") in
194194+ let sources =
195195+ match Sources_registry.load ~fs:(fs :> _ Eio.Path.t) sources_path with
196196+ | Ok s -> s
197197+ | Error _ -> Sources_registry.empty
198198+ in
199199+ let entry = Sources_registry.{
200200+ url = normalize_git_url url;
201201+ upstream = None;
202202+ branch = Some "main";
203203+ reason = None;
204204+ origin = Some Fork;
205205+ } in
206206+ let sources = Sources_registry.add sources ~subtree:name entry in
207207+ (match Sources_registry.save ~fs:(fs :> _ Eio.Path.t) sources_path sources with
208208+ | Ok () -> ()
209209+ | Error msg -> Logs.warn (fun m -> m "Failed to update sources.toml: %s" msg))
210210+ | None -> ());
212211 Ok { name; split_commit; src_path; push_url; packages_created = packages }))
213212 end
214213 end
···240239 | Ok () ->
241240 (* Find .opam files in the new subtree *)
242241 let packages = find_opam_files ~fs subtree_path in
243243- (* Update sources.toml with join entry *)
244244- let sources_path = Fpath.(monorepo / "sources.toml") in
245245- let sources =
246246- match Sources_registry.load ~fs:(fs :> _ Eio.Path.t) sources_path with
247247- | Ok s -> s
248248- | Error _ -> Sources_registry.empty
249249- in
250250- let entry = Sources_registry.{
251251- url = normalize_git_url url;
252252- upstream = Option.map normalize_git_url upstream;
253253- branch = Some branch;
254254- reason = Some "Joined to monorepo";
255255- origin = Some Join;
256256- } in
257257- let sources = Sources_registry.add sources ~subtree:name entry in
258258- (match Sources_registry.save ~fs:(fs :> _ Eio.Path.t) sources_path sources with
259259- | Ok () -> ()
260260- | Error msg -> Logs.warn (fun m -> m "Failed to update sources.toml: %s" msg));
242242+ (* Only update sources.toml if there's an upstream to track *)
243243+ (match upstream with
244244+ | Some _ ->
245245+ let sources_path = Fpath.(monorepo / "sources.toml") in
246246+ let sources =
247247+ match Sources_registry.load ~fs:(fs :> _ Eio.Path.t) sources_path with
248248+ | Ok s -> s
249249+ | Error _ -> Sources_registry.empty
250250+ in
251251+ let entry = Sources_registry.{
252252+ url = normalize_git_url url;
253253+ upstream = Option.map normalize_git_url upstream;
254254+ branch = Some branch;
255255+ reason = None;
256256+ origin = Some Join;
257257+ } in
258258+ let sources = Sources_registry.add sources ~subtree:name entry in
259259+ (match Sources_registry.save ~fs:(fs :> _ Eio.Path.t) sources_path sources with
260260+ | Ok () -> ()
261261+ | Error msg -> Logs.warn (fun m -> m "Failed to update sources.toml: %s" msg))
262262+ | None -> ());
261263 Ok { name; source_url = url; upstream_url = upstream; packages_added = packages; from_handle = None }
262264 end
263265
+71-4
lib/monopam.ml
···246246 in
247247248248 (* URL resolution order:
249249- 1. sources.toml override
250250- 2. dune-project source/homepage
251251- 3. existing opam-repo dev-repo (fallback) *)
252252- (* URL resolution order:
253249 1. Explicit sources.toml entry for this subtree
254250 2. dune-project source/homepage
255251 3. sources.toml default_url_base + subtree name *)
···14791475 if !updated > 0 then
14801476 Log.info (fun m -> m "Regenerated %d opam-repo entries from monorepo" !updated)
1481147714781478+(** Clone monorepo and opam-repo from verse registry if they don't exist locally.
14791479+ This enables `monopam sync` to work in a fresh devcontainer. *)
14801480+let clone_from_verse_if_needed ~proc ~fs ~config () =
14811481+ let monorepo = Config.Paths.monorepo config in
14821482+ let opam_repo = Config.Paths.opam_repo config in
14831483+ let monorepo_exists = Git.is_repo ~proc ~fs monorepo in
14841484+ let opam_repo_exists = Git.is_repo ~proc ~fs opam_repo in
14851485+14861486+ (* If both exist, nothing to do *)
14871487+ if monorepo_exists && opam_repo_exists then Ok ()
14881488+ else
14891489+ (* Try to load verse config to get handle *)
14901490+ match Verse_config.load ~fs () with
14911491+ | Error _ ->
14921492+ (* No verse config - can't clone from registry *)
14931493+ Log.debug (fun m -> m "No verse config found, will initialize fresh repos");
14941494+ Ok ()
14951495+ | Ok verse_config ->
14961496+ let handle = Verse_config.handle verse_config in
14971497+ Log.info (fun m -> m "Found verse config for handle: %s" handle);
14981498+ (* Load registry to look up URLs *)
14991499+ match Verse_registry.clone_or_pull ~proc ~fs ~config:verse_config () with
15001500+ | Error msg ->
15011501+ Log.warn (fun m -> m "Could not load verse registry: %s" msg);
15021502+ Ok () (* Continue without cloning - will init fresh *)
15031503+ | Ok registry ->
15041504+ match Verse_registry.find_member registry ~handle with
15051505+ | None ->
15061506+ Log.warn (fun m -> m "Handle %s not found in registry" handle);
15071507+ Ok ()
15081508+ | Some member ->
15091509+ (* Clone monorepo if needed *)
15101510+ let result =
15111511+ if monorepo_exists then Ok ()
15121512+ else begin
15131513+ Log.app (fun m -> m "Cloning monorepo from %s..." member.monorepo);
15141514+ let url = Uri.of_string member.monorepo in
15151515+ let branch = Option.value ~default:"main" member.monorepo_branch in
15161516+ match Git.clone ~proc ~fs ~url ~branch monorepo with
15171517+ | Ok () ->
15181518+ Log.app (fun m -> m "Monorepo cloned successfully");
15191519+ Ok ()
15201520+ | Error e ->
15211521+ Log.err (fun m -> m "Failed to clone monorepo: %a" Git.pp_error e);
15221522+ Error (Git_error e)
15231523+ end
15241524+ in
15251525+ match result with
15261526+ | Error e -> Error e
15271527+ | Ok () ->
15281528+ (* Clone opam-repo if needed *)
15291529+ if opam_repo_exists then Ok ()
15301530+ else begin
15311531+ Log.app (fun m -> m "Cloning opam-repo from %s..." member.opamrepo);
15321532+ let url = Uri.of_string member.opamrepo in
15331533+ let branch = Option.value ~default:"main" member.opamrepo_branch in
15341534+ match Git.clone ~proc ~fs ~url ~branch opam_repo with
15351535+ | Ok () ->
15361536+ Log.app (fun m -> m "Opam-repo cloned successfully");
15371537+ Ok ()
15381538+ | Error e ->
15391539+ Log.err (fun m -> m "Failed to clone opam-repo: %a" Git.pp_error e);
15401540+ Error (Git_error e)
15411541+ end
15421542+14821543let sync ~proc ~fs ~config ?package ?(remote = false) ?(skip_push = false)
14831544 ?(skip_pull = false) () =
14841545 let fs_t = fs_typed fs in
15461546+15471547+ (* Clone from verse registry if repos don't exist *)
15481548+ match clone_from_verse_if_needed ~proc ~fs:fs_t ~config () with
15491549+ | Error e -> Error e
15501550+ | Ok () ->
15511551+14851552 (* Update the opam repo first - clone if needed *)
14861553 let opam_repo = Config.Paths.opam_repo config in
14871554 if (not skip_pull) && Git.is_repo ~proc ~fs:fs_t opam_repo then begin
···12121313(** {1 Types} *)
14141515-(** Package-level override for vendored packages. *)
1515+(** Package-level override for vendored packages.
1616+1717+ Note: For dev-repo URL overrides, use [sources.toml] in the monorepo root instead.
1818+ This type only supports branch overrides. *)
1619type package_override = {
1717- dev_repo : string option; (** Override dev-repo URL for opam-repo generation *)
1820 branch : string option; (** Override git branch *)
1921}
2022···3840 Each entry is [(subtree_name, override)] where subtree_name is the
3941 directory name in the monorepo (e.g., "braid" for mono/braid/).
40424141- Use this to override dev-repo URLs for vendored packages. *)
4343+ Use this to override git branches. For dev-repo URL overrides,
4444+ use [sources.toml] in the monorepo root instead. *)
42454346(** {1 Derived Paths} *)
4447