Monorepo management for opam overlays
0
fork

Configure Feed

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

monopam/root: derive scan_dirs from the filesystem, not Package URLs

collect_external_deps used Package.subtree_prefix (which derives
the directory name from the basename of the dev-repo: URL) to pick
which subtrees to scan. That works only when the URL basename
matches the in-monorepo subtree directory.

Forks intentionally violate that: their dev-repo: now points at the
upstream URL so opam-repository directs users at the canonical home,
which means the URL basename (e.g. ocaml-claudeio, ocaml-cbort) no
longer matches the in-monorepo subtree (ocaml-claude, ocaml-cbor).
The result was that internal packages from forked subtrees leaked
into root.opam as "external" deps.

Walking subtree_dirs directly aligns the dep collection and the
internal-package exclusion set with the actual layout, regardless
of what each .opam declares as its dev-repo.

+9 -18
+9 -18
lib/root.ml
··· 391 391 392 392 (** {1 Dependency collection} *) 393 393 394 - let collect_external_deps ~fs ~monorepo pkgs = 395 - let seen = Hashtbl.create 16 in 396 - let repos = 397 - List.filter 398 - (fun pkg -> 399 - let repo = Package.repo_name pkg in 400 - if Hashtbl.mem seen repo then false 401 - else begin 402 - Hashtbl.add seen repo (); 403 - true 404 - end) 405 - pkgs 406 - in 407 - let scan_dirs = 408 - match repos with 409 - | [] -> subtree_dirs ~fs monorepo 410 - | _ -> List.map Package.subtree_prefix repos 411 - in 394 + let collect_external_deps ~fs ~monorepo _pkgs = 395 + (* Iterate the actual subtree directories on disk rather than deriving them 396 + from each package's dev-repo URL via [Package.repo_name]. For a fork, the 397 + dev-repo: field intentionally points at upstream (so opam-repository 398 + directs users at the canonical home), which means the URL basename does 399 + not match the in-monorepo subtree directory. Walking [subtree_dirs] 400 + keeps the dep collection and the internal-package exclusion set aligned 401 + with the real layout. *) 402 + let scan_dirs = subtree_dirs ~fs monorepo in 412 403 let all_deps = 413 404 List.concat_map 414 405 (fun dir -> Opam_repo.scan_opam_files_for_deps ~fs Fpath.(monorepo / dir))