Monorepo management for opam overlays
0
fork

Configure Feed

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

monopam: remove redundant function prefixes

Rename functions to remove get_/find_ prefixes:
- verse_registry: find_member -> member, find_members -> members
- verse: get_tracked_handles -> tracked_handles,
get_verse_subtrees -> verse_subtrees
- cross_status: get_subtree_info -> subtree_info
- status: get_subtree_hashes -> subtree_hashes
- forks: get_cached_scan -> cached_scan, get_ref_commit -> ref_commit
- monopam: get_branch -> branch, get_behind -> behind

+33 -34
+5 -5
lib/cross_status.ml
··· 139 139 end 140 140 141 141 (** Get subtree info for a given prefix in a monorepo. *) 142 - let get_subtree_info ~fs ~monorepo_path ~prefix () : subtree_info = 142 + let subtree_info ~fs ~monorepo_path ~prefix () : subtree_info = 143 143 let repo = Git.Repository.open_repo ~fs monorepo_path in 144 144 let upstream_commit = 145 145 Git.Repository.subtree_last_upstream_commit repo ~prefix ··· 212 212 let my_subtrees = Verse.scan_subtrees ~fs my_mono in 213 213 214 214 (* Get verse subtrees (map: repo_name -> [(handle, monorepo_path)]) *) 215 - let verse_subtrees = Verse.get_verse_subtrees ~fs ~config:verse_config () in 215 + let verse_subtrees = Verse.verse_subtrees ~fs ~config:verse_config () in 216 216 217 217 (* Build comparisons for repos I have *) 218 218 let my_repos = 219 219 List.filter_map 220 220 (fun repo_name -> 221 221 let my_info = 222 - get_subtree_info ~fs ~monorepo_path:my_mono ~prefix:repo_name () 222 + subtree_info ~fs ~monorepo_path:my_mono ~prefix:repo_name () 223 223 in 224 224 let checkout_path = Fpath.(checkouts / repo_name) in 225 225 ··· 234 234 List.map 235 235 (fun (handle, their_mono) -> 236 236 let their_info = 237 - get_subtree_info ~fs ~monorepo_path:their_mono 238 - ~prefix:repo_name () 237 + subtree_info ~fs ~monorepo_path:their_mono ~prefix:repo_name 238 + () 239 239 in 240 240 let rel = 241 241 compare_commits ~fs ~checkout_path
+5 -5
lib/forks.ml
··· 159 159 with _ -> () 160 160 161 161 (** Get cached scan results for a path, or None if not cached *) 162 - let get_cached_scan path = 162 + let cached_scan path = 163 163 if Hashtbl.length scan_cache = 0 then load_scan_cache (); 164 164 Hashtbl.find_opt scan_cache (Fpath.to_string path) 165 165 ··· 522 522 let did_fetch = fetch_verse_opam_repo ~proc ~fs ~refresh opam_path in 523 523 (* Use cached scan results unless we fetched or have no cache *) 524 524 let pkg_urls = 525 - match (did_fetch, get_cached_scan opam_path) with 525 + match (did_fetch, cached_scan opam_path) with 526 526 | false, Some cached -> 527 527 Log.debug (fun m -> m "Using cached scan for %a" Fpath.pp opam_path); 528 528 cached ··· 622 622 end 623 623 624 624 (** Get the commit hash for a ref *) 625 - let get_ref_commit ~fs ~repo ref_name = 625 + let ref_commit ~fs ~repo ref_name = 626 626 let git_repo = Git.Repository.open_repo ~fs repo in 627 627 (* Handle refs like "origin/main" or "verse/handle/main" *) 628 628 let ref_path = ··· 635 635 636 636 (** Compare two refs and determine relationship *) 637 637 let compare_refs ~fs ~repo ~my_ref ~their_ref () = 638 - let my_commit = get_ref_commit ~fs ~repo my_ref in 639 - let their_commit = get_ref_commit ~fs ~repo their_ref in 638 + let my_commit = ref_commit ~fs ~repo my_ref in 639 + let their_commit = ref_commit ~fs ~repo their_ref in 640 640 match (my_commit, their_commit) with 641 641 | None, _ | _, None -> Not_fetched 642 642 | Some my_hash, Some their_hash when Git.Hash.equal my_hash their_hash ->
+13 -14
lib/monopam.ml
··· 206 206 with Eio.Io _ -> []) 207 207 repos 208 208 209 - let get_branch ~config pkg = 209 + let branch ~config pkg = 210 210 let default = Config.default_branch in 211 211 match Package.branch pkg with 212 212 | Some b -> b ··· 220 220 let checkouts_root = Config.Paths.checkouts config in 221 221 let checkout_dir = Package.checkout_dir ~checkouts_root pkg in 222 222 let checkout_eio = Eio.Path.(fs / Fpath.to_string checkout_dir) in 223 - let branch = get_branch ~config pkg in 223 + let branch = branch ~config pkg in 224 224 let do_clone () = 225 225 Log.info (fun m -> 226 226 m "Cloning %s from %a (branch: %s)" (Package.repo_name pkg) Uri.pp ··· 750 750 let monorepo = Config.Paths.monorepo config in 751 751 let checkouts_root = Config.Paths.checkouts config in 752 752 let prefix = Package.subtree_prefix pkg in 753 - let branch = get_branch ~config pkg in 753 + let branch = branch ~config pkg in 754 754 (* Pull from local checkout, not remote URL - ensures push/pull use same source *) 755 755 let checkout_dir = Package.checkout_dir ~checkouts_root pkg in 756 756 let url = Uri.of_string (Fpath.to_string checkout_dir) in ··· 812 812 | exception Eio.Io _ -> false 813 813 814 814 (* Get commits behind before fetching *) 815 - let get_behind ~proc:_ ~fs ~config pkg = 815 + let behind ~proc:_ ~fs ~config pkg = 816 816 let checkouts_root = Config.Paths.checkouts config in 817 817 let checkout_dir = Package.checkout_dir ~checkouts_root pkg in 818 - let branch = get_branch ~config pkg in 818 + let branch = branch ~config pkg in 819 819 if not (Git.Repository.is_repo ~fs checkout_dir) then 0 820 820 else 821 821 let repo = Git.Repository.open_repo ~fs checkout_dir in ··· 898 898 m "[%d/%d] Fetching repo %s" i total repo_name); 899 899 let existed = checkout_exists ~fs:fs_t ~config pkg in 900 900 let behind_before = 901 - if existed then get_behind ~proc ~fs:fs_t ~config pkg 902 - else 0 901 + if existed then behind ~proc ~fs:fs_t ~config pkg else 0 903 902 in 904 903 match ensure_checkout ~proc ~fs:fs_t ~config pkg with 905 904 | Error e -> Error (Git_error e) ··· 1005 1004 let prefix = Package.subtree_prefix pkg in 1006 1005 let checkouts_root = Config.Paths.checkouts config in 1007 1006 let checkout_dir = Package.checkout_dir ~checkouts_root pkg in 1008 - let branch = get_branch ~config pkg in 1007 + let branch = branch ~config pkg in 1009 1008 if not (is_directory ~fs Fpath.(monorepo / prefix)) then begin 1010 1009 Log.debug (fun m -> m "Subtree %s not in monorepo, skipping" prefix); 1011 1010 Ok () ··· 1122 1121 let checkout_dir = 1123 1122 Package.checkout_dir ~checkouts_root pkg 1124 1123 in 1125 - let branch = get_branch ~config pkg in 1124 + let branch = branch ~config pkg in 1126 1125 let push_url = url_to_push_url (Package.dev_repo pkg) in 1127 1126 Log.info (fun m -> 1128 1127 m "Pushing %s to %s" (Package.repo_name pkg) push_url); ··· 1312 1311 let checkouts_root = Config.Paths.checkouts config in 1313 1312 let checkout_dir = Package.checkout_dir ~checkouts_root pkg in 1314 1313 let checkout_eio = Eio.Path.(fs / Fpath.to_string checkout_dir) in 1315 - let branch = get_branch ~config pkg in 1314 + let branch = branch ~config pkg in 1316 1315 let is_directory = 1317 1316 match Eio.Path.kind ~follow:true checkout_eio with 1318 1317 | `Directory -> true ··· 1387 1386 let repo = Package.repo_name pkg in 1388 1387 let checkouts_root = Config.Paths.checkouts config in 1389 1388 let checkout_dir = Package.checkout_dir ~checkouts_root pkg in 1390 - let branch = get_branch ~config pkg in 1389 + let branch = branch ~config pkg in 1391 1390 let remote_url = Package.dev_repo pkg in 1392 1391 let local_head = 1393 1392 let repo = Git.Repository.open_repo ~fs checkout_dir in ··· 1436 1435 let merge_checkout_safe ~proc ~fs ~config pkg = 1437 1436 let checkouts_root = Config.Paths.checkouts config in 1438 1437 let checkout_dir = Package.checkout_dir ~checkouts_root pkg in 1439 - let branch = get_branch ~config pkg in 1438 + let branch = branch ~config pkg in 1440 1439 Log.info (fun m -> m "Merging %s to %s" (Package.repo_name pkg) branch); 1441 1440 Git_cli.merge_ff ~proc ~fs ~branch checkout_dir 1442 1441 ··· 1444 1443 let push_remote_safe ~proc ~fs ~config pkg = 1445 1444 let checkouts_root = Config.Paths.checkouts config in 1446 1445 let checkout_dir = Package.checkout_dir ~checkouts_root pkg in 1447 - let branch = get_branch ~config pkg in 1446 + let branch = branch ~config pkg in 1448 1447 let push_url = url_to_push_url (Package.dev_repo pkg) in 1449 1448 Log.info (fun m -> m "Pushing %s to %s" (Package.repo_name pkg) push_url); 1450 1449 (* Set the push URL for origin *) ··· 1524 1523 (* Sync verse remotes for all repos *) 1525 1524 let sync_verse_remotes ~fs ~config ~verse_config repos = 1526 1525 Log.app (fun m -> m " Updating verse remotes..."); 1527 - let verse_subtrees = Verse.get_verse_subtrees ~fs ~config:verse_config () in 1526 + let verse_subtrees = Verse.verse_subtrees ~fs ~config:verse_config () in 1528 1527 List.iter 1529 1528 (fun pkg -> ensure_verse_remotes_for_repo ~fs ~config ~verse_subtrees pkg) 1530 1529 repos
+3 -3
lib/status.ml
··· 35 35 { ahead = ab.ahead; behind = ab.behind } 36 36 37 37 (** Pre-compute all subtree hashes from mono repo's HEAD *) 38 - let get_subtree_hashes ~fs ~monorepo = 38 + let subtree_hashes ~fs ~monorepo = 39 39 let mono_repo = Git.Repository.open_repo ~fs monorepo in 40 40 match Git.Repository.read_ref mono_repo "HEAD" with 41 41 | None -> Hashtbl.create 0 ··· 100 100 let fs_t = fs_typed fs in 101 101 let checkouts_root = Config.Paths.checkouts config in 102 102 let monorepo = Config.Paths.monorepo config in 103 - let subtree_hashes = get_subtree_hashes ~fs:fs_t ~monorepo in 103 + let subtree_hashes = subtree_hashes ~fs:fs_t ~monorepo in 104 104 compute_one ~fs:fs_t ~checkouts_root ~monorepo ~subtree_hashes pkg 105 105 106 106 let compute_all ~fs ~config packages = ··· 108 108 let checkouts_root = Config.Paths.checkouts config in 109 109 let monorepo = Config.Paths.monorepo config in 110 110 (* Pre-compute all subtree hashes once *) 111 - let subtree_hashes = get_subtree_hashes ~fs:fs_t ~monorepo in 111 + let subtree_hashes = subtree_hashes ~fs:fs_t ~monorepo in 112 112 Eio.Fiber.List.map ~max_fibers:8 113 113 (compute_one ~fs:fs_t ~checkouts_root ~monorepo ~subtree_hashes) 114 114 packages
+4 -4
lib/verse.ml
··· 127 127 try Eio.Path.mkdirs ~perm:0o755 eio_path with Eio.Io _ -> () 128 128 129 129 (* Get list of tracked members by looking at verse/ directory *) 130 - let get_tracked_handles ~fs config = 130 + let tracked_handles ~fs config = 131 131 let verse_path = Verse_config.verse_path config in 132 132 if not (is_directory ~fs verse_path) then [] 133 133 else ··· 232 232 | Error msg -> Error (Registry_error msg) 233 233 | Ok registry -> 234 234 (* Get tracked handles *) 235 - let tracked_handles = get_tracked_handles ~fs config in 235 + let tracked_handles = tracked_handles ~fs config in 236 236 (* Build status for each tracked member *) 237 237 let tracked_members = 238 238 List.filter_map ··· 404 404 405 405 (** Get subtrees from all tracked verse members. Returns a map from subtree name 406 406 to list of (handle, monorepo_path) pairs. *) 407 - let get_verse_subtrees ~fs ~config () = 407 + let verse_subtrees ~fs ~config () = 408 408 let verse_path = Verse_config.verse_path config in 409 - let tracked_handles = get_tracked_handles ~fs config in 409 + let tracked_handles = tracked_handles ~fs config in 410 410 (* Build map: subtree_name -> [(handle, monorepo_path)] *) 411 411 let subtree_map = Hashtbl.create 64 in 412 412 List.iter
+3 -3
lib/verse.mli
··· 133 133 134 134 Filters out hidden directories, _build, node_modules, etc. *) 135 135 136 - val get_verse_subtrees : 136 + val verse_subtrees : 137 137 fs:Eio.Fs.dir_ty Eio.Path.t -> 138 138 config:Verse_config.t -> 139 139 unit -> 140 140 (string, (string * Fpath.t) list) Hashtbl.t 141 - (** [get_verse_subtrees ~fs ~config ()] scans all tracked verse members and 142 - returns a map from subtree name to list of (handle, monorepo_path) pairs. 141 + (** [verse_subtrees ~fs ~config ()] scans all tracked verse members and returns 142 + a map from subtree name to list of (handle, monorepo_path) pairs. 143 143 144 144 This allows finding which verse users have a particular repo. *) 145 145