Monorepo management for opam overlays
0
fork

Configure Feed

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

Fix synopsis selection for multi-opam repos; add test

Use ocaml- prefix stripping to find the main package (e.g. "scitt"
for repo "ocaml-scitt") instead of picking the first alphabetically
("atp-lexicon-scitt"). Added test verifying the correct synopsis is
selected for ocaml-scitt's three opam files.

+56 -1
+13 -1
lib/push.ml
··· 427 427 let name = Package.repo_name pkg in 428 428 (* Find the package whose name matches the repo name for the best 429 429 synopsis (e.g. "scitt" for ocaml-scitt, not "atp-lexicon-scitt") *) 430 + (* Find the main package: prefer exact name match, then 431 + name matching with ocaml- prefix stripped. *) 432 + let stripped = 433 + if String.starts_with ~prefix:"ocaml-" name then 434 + String.sub name 6 (String.length name - 6) 435 + else name 436 + in 430 437 let best = 431 438 match List.find_opt (fun p -> Package.name p = name) all_pkgs with 432 439 | Some p -> p 433 - | None -> pkg 440 + | None -> ( 441 + match 442 + List.find_opt (fun p -> Package.name p = stripped) all_pkgs 443 + with 444 + | Some p -> p 445 + | None -> pkg) 434 446 in 435 447 let synopsis = 436 448 Option.value ~default:"OCaml library" (Package.synopsis best)
+43
test/test_package.ml
··· 144 144 let pkg = Package.v ~name:"d3t" ~version:"dev" ~dev_repo () in 145 145 Alcotest.(check bool) "no match" false (Package.matches_name "other" pkg) 146 146 147 + (* Test that for multi-opam repos, matches_name finds the main package 148 + so log_missing_repos picks the right synopsis. *) 149 + let test_best_synopsis_for_multi_opam_repo () = 150 + let dev_repo = 151 + Uri.of_string "https://tangled.org/gazagnaire.org/ocaml-scitt" 152 + in 153 + let lexicon = 154 + Package.v ~name:"atp-lexicon-scitt" ~version:"dev" ~dev_repo 155 + ~synopsis:"AT Proto lexicons for SCITT" () 156 + in 157 + let main = 158 + Package.v ~name:"scitt" ~version:"dev" ~dev_repo 159 + ~synopsis:"Supply Chain Integrity, Transparency, and Trust (IETF SCITT)" 160 + () 161 + in 162 + let scitt_atp = 163 + Package.v ~name:"scitt-atp" ~version:"dev" ~dev_repo 164 + ~synopsis:"AT Proto MST backend for SCITT" () 165 + in 166 + let all_pkgs = [ lexicon; main; scitt_atp ] in 167 + let repo_name = Package.repo_name lexicon in 168 + Alcotest.(check string) "repo name" "ocaml-scitt" repo_name; 169 + (* Strip ocaml- prefix to find "scitt" matching the main package *) 170 + let stripped = 171 + if String.starts_with ~prefix:"ocaml-" repo_name then 172 + String.sub repo_name 6 (String.length repo_name - 6) 173 + else repo_name 174 + in 175 + let best = 176 + match List.find_opt (fun p -> Package.name p = repo_name) all_pkgs with 177 + | Some p -> p 178 + | None -> ( 179 + match List.find_opt (fun p -> Package.name p = stripped) all_pkgs with 180 + | Some p -> p 181 + | None -> lexicon) 182 + in 183 + Alcotest.(check string) 184 + "best synopsis" 185 + "Supply Chain Integrity, Transparency, and Trust (IETF SCITT)" 186 + (Option.value ~default:"" (Package.synopsis best)) 187 + 147 188 let suite = 148 189 ( "package", 149 190 [ ··· 166 207 Alcotest.test_case "by name" `Quick test_matches_name_by_name; 167 208 Alcotest.test_case "by repo name" `Quick test_matches_name_by_repo; 168 209 Alcotest.test_case "no match" `Quick test_matches_name_no_match; 210 + Alcotest.test_case "multi-opam synopsis" `Quick 211 + test_best_synopsis_for_multi_opam_repo; 169 212 ] )