Monorepo management for opam overlays
0
fork

Configure Feed

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

fix(monopam): omit branch fragment for origin URLs, push opam-repo always

- pkg.ml: when using origin-derived HTTPS URL for opam files, omit the
branch fragment so git uses the repo default. Entry branch is only
used when falling back to the entry source URL (no origin configured).

- push.ml: always push workspace repos (opam-repo) when upstream=true,
even when all package repos are already in sync.

+35 -28
+18 -12
lib/pkg.ml
··· 50 50 | Some entry -> 51 51 (* Use the public HTTPS URL (from origin) for opam, 52 52 falling back to the entry source if no origin is configured. *) 53 - let dev_repo = 53 + let dev_repo, url_src = 54 54 match derive_from_origin () with 55 - | Some url -> url 56 - | None -> entry.Sources_registry.source 57 - in 58 - let branch = 59 - match entry.Sources_registry.branch with 60 - | Some b -> b 61 - | None -> ( 62 - match dune_proj.Dune_project.source with 63 - | Some (Dune_project.Uri { branch = Some b; _ }) -> b 64 - | _ -> "main") 55 + | Some url -> 56 + (* Origin URL points to where monopam pushes — don't specify 57 + branch, let git pick the default *) 58 + (url, url) 59 + | None -> 60 + (* Fallback to entry source — use its branch *) 61 + let branch = 62 + match entry.Sources_registry.branch with 63 + | Some b -> b 64 + | None -> ( 65 + match dune_proj.Dune_project.source with 66 + | Some (Dune_project.Uri { branch = Some b; _ }) -> b 67 + | _ -> "main") 68 + in 69 + ( entry.Sources_registry.source, 70 + entry.Sources_registry.source ^ "#" ^ branch ) 65 71 in 66 72 Log.debug (fun m -> 67 73 m "Using sources.toml entry for %s: %s" subtree dev_repo); 68 - Some (dev_repo, dev_repo ^ "#" ^ branch) 74 + Some (dev_repo, url_src) 69 75 | None -> ( 70 76 match derive_from_dune () with 71 77 | Some result -> Some result
+3 -1
lib/push.ml
··· 440 440 mono_entries ~proc ~fs ~config ~sources ~clean; 441 441 let to_push = repos_to_push statuses pkgs in 442 442 Log.info (fun m -> m "Pushing %d unique repos" (List.length to_push)); 443 + let push_mono = packages = [] in 443 444 if to_push = [] then begin 444 445 Log.app (fun m -> m "Nothing to push (all repos in sync)"); 446 + if upstream then 447 + workspace_repos ~proc ~fs:fs_t ~config ~force ~push_mono; 445 448 Ok () 446 449 end 447 450 else 448 - let push_mono = packages = [] in 449 451 export_and_push ~proc ~fs ~fs_t ~config ~sources ~upstream 450 452 ~push_mono ~clean ~force to_push 451 453 end
+14 -15
test/test_pkg.ml
··· 51 51 let dp = 52 52 dune_proj ~source:(Github { user = "janestreet"; repo = "memtrace" }) () 53 53 in 54 - check_dev_repo "sources.toml entry + origin → HTTPS URL" 54 + check_dev_repo "sources.toml entry + origin → HTTPS URL, no branch" 55 55 (Some 56 56 ( "git+https://tangled.org/gazagnaire.org/memtrace", 57 - "git+https://tangled.org/gazagnaire.org/memtrace#main" )) 57 + "git+https://tangled.org/gazagnaire.org/memtrace" )) 58 58 (Pkg.derive_dev_repo ~sources ~subtree:"memtrace" dp) 59 59 60 60 let test_derive_sources_override_with_branch () = 61 - (* With origin set, HTTPS URL is used; branch comes from entry *) 61 + (* With origin set, HTTPS URL + main branch (monopam push target) *) 62 62 let sources = 63 63 SR.with_origin SR.empty "git+https://tangled.org/gazagnaire.org" |> fun s -> 64 64 SR.add s ~subtree:"memtrace" ··· 66 66 "git@git.recoil.org:gazagnaire.org/memtrace") 67 67 in 68 68 let dp = dune_proj () in 69 - check_dev_repo "sources.toml branch used with HTTPS URL" 69 + check_dev_repo "origin URL, no branch fragment" 70 70 (Some 71 71 ( "git+https://tangled.org/gazagnaire.org/memtrace", 72 - "git+https://tangled.org/gazagnaire.org/memtrace#master" )) 72 + "git+https://tangled.org/gazagnaire.org/memtrace" )) 73 73 (Pkg.derive_dev_repo ~sources ~subtree:"memtrace" dp) 74 74 75 75 let test_derive_sources_override_no_origin () = 76 - (* Without origin, the entry SSH source is used as fallback *) 76 + (* Without origin, the entry SSH source and branch are used *) 77 77 let sources = 78 78 SR.add SR.empty ~subtree:"memtrace" 79 - (sr_entry "git@git.recoil.org:gazagnaire.org/memtrace") 79 + (sr_entry ~branch:(Some "master") 80 + "git@git.recoil.org:gazagnaire.org/memtrace") 80 81 in 81 82 let dp = dune_proj () in 82 - check_dev_repo "no origin → falls back to entry source" 83 + check_dev_repo "no origin → entry source + entry branch" 83 84 (Some 84 85 ( "git@git.recoil.org:gazagnaire.org/memtrace", 85 - "git@git.recoil.org:gazagnaire.org/memtrace#main" )) 86 + "git@git.recoil.org:gazagnaire.org/memtrace#master" )) 86 87 (Pkg.derive_dev_repo ~sources ~subtree:"memtrace" dp) 87 88 88 89 let test_derive_sources_override_branch_from_dune () = ··· 199 200 let dp = dune_proj ~source:(Github { user = "upstream"; repo = "pkg" }) () in 200 201 check_dev_repo "sources.toml takes priority over github dune-project" 201 202 (Some 202 - ( "git+https://tangled.org/user/pkg", 203 - "git+https://tangled.org/user/pkg#main" )) 203 + ("git+https://tangled.org/user/pkg", "git+https://tangled.org/user/pkg")) 204 204 (Pkg.derive_dev_repo ~sources ~subtree:"pkg" dp) 205 205 206 206 let test_derive_dune_wins_over_origin () = ··· 221 221 let dp = dune_proj () in 222 222 check_dev_repo "origin HTTPS URL used even when entry has different URL" 223 223 (Some 224 - ( "git+https://tangled.org/user/pkg", 225 - "git+https://tangled.org/user/pkg#main" )) 224 + ("git+https://tangled.org/user/pkg", "git+https://tangled.org/user/pkg")) 226 225 (Pkg.derive_dev_repo ~sources ~subtree:"pkg" dp) 227 226 228 227 (* {1 derive_dev_repo: real-world scenarios} *) ··· 241 240 let dp = 242 241 dune_proj ~source:(Github { user = "janestreet"; repo = "memtrace" }) () 243 242 in 244 - check_dev_repo "memtrace: HTTPS origin URL used for opam, not SSH entry" 243 + check_dev_repo "memtrace: HTTPS origin URL, default branch" 245 244 (Some 246 245 ( "git+https://tangled.org/gazagnaire.org/memtrace", 247 - "git+https://tangled.org/gazagnaire.org/memtrace#master" )) 246 + "git+https://tangled.org/gazagnaire.org/memtrace" )) 248 247 (Pkg.derive_dev_repo ~sources ~subtree:"memtrace" dp) 249 248 250 249 let test_derive_no_entry_uses_dune_project () =