Monorepo management for opam overlays
0
fork

Configure Feed

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

monopam/lint: flag subtrees whose dune-project lacks (source ...)

Without a (source ...) stanza the generated .opam files lack a
dev-repo: field, which breaks downstream tooling that uses dev-repo
to map a package back to its subtree (e.g. root.opam external-dep
filtering, which previously left every internal package in the root
deps because Package.repo_name fell back to the empty string).

Distinguish "no dune-project" (legitimately not an OCaml subtree)
from "dune-project without source" (always a bug) and report the
latter alongside source/sources.toml mismatches.

+14 -7
+14 -7
lib/lint.ml
··· 419 419 if String.ends_with ~suffix:".git" u then String.sub u 0 (String.length u - 4) 420 420 else u 421 421 422 + type dune_source_state = No_dune_project | No_source | Has_source of string 423 + 422 424 let load_dune_project_source ~fs subtree_path = 423 425 let dune_project_path = Fpath.(subtree_path / "dune-project") in 424 426 let eio_path = Eio.Path.(fs / Fpath.to_string dune_project_path) in 425 427 match Eio.Path.kind ~follow:false eio_path with 426 428 | `Regular_file -> ( 427 429 match try Some (Eio.Path.load eio_path) with Eio.Io _ -> None with 428 - | None -> None 430 + | None -> No_dune_project 429 431 | Some content -> ( 430 432 match Dune_project.parse content with 431 - | Error _ -> None 433 + | Error _ -> No_source 432 434 | Ok dp -> ( 433 435 match Dune_project.dev_repo_url dp with 434 - | Ok url -> Some (normalise_url url) 435 - | Error _ -> None))) 436 - | _ | (exception Eio.Io _) -> None 436 + | Ok url -> Has_source (normalise_url url) 437 + | Error _ -> No_source))) 438 + | _ | (exception Eio.Io _) -> No_dune_project 437 439 438 440 let compute_source_issues ~fs ~monorepo ~sources subdirs = 439 441 List.filter_map ··· 450 452 | None -> None 451 453 in 452 454 match dune with 453 - | None -> None 454 - | Some d -> 455 + | No_dune_project -> None 456 + | No_source -> 457 + (* Without a (source ...) stanza dune emits no dev-repo: in the 458 + generated .opam, which breaks downstream tooling that reads 459 + dev-repo to identify the subtree (e.g. root.opam dep filtering). *) 460 + Some { subtree; dune_project = None; sources_toml = source } 461 + | Has_source d -> 455 462 let matches_source = 456 463 match source with Some s -> s = d | None -> false 457 464 in