Monorepo management for opam overlays
at main 84 lines 3.0 kB view raw
1(** Cross-user repository comparison for monopam. 2 3 Compares subtrees across multiple verse users' monorepos to identify common 4 repositories and their relative commit states. *) 5 6(** {1 Types} *) 7 8(** Relationship between two subtree commits. *) 9type relationship = 10 | Same (** Commits are the same *) 11 | I_am_ahead of int (** My commit is ahead by N commits *) 12 | I_am_behind of int (** My commit is behind by N commits *) 13 | Diverged of { my_ahead : int; their_ahead : int } 14 (** Commits have diverged from a common ancestor *) 15 | Unknown (** Cannot determine relationship (missing commits, etc.) *) 16 17type subtree_info = { 18 monorepo_path : Fpath.t; (** Path to the monorepo *) 19 prefix : string; (** Subtree directory name *) 20 upstream_commit : string option; (** Last synced upstream commit SHA *) 21} 22(** Information about a subtree in a monorepo. *) 23 24type repo_comparison = { 25 repo_name : string; (** Repository/subtree name *) 26 my_info : subtree_info option; 27 (** My subtree info (None if not in my mono) *) 28 others : (string * subtree_info * relationship) list; 29 (** List of (handle, info, relationship to me) *) 30} 31(** Comparison of a repo across multiple users. *) 32 33type t = { 34 my_repos : repo_comparison list; (** Repos I have, compared against others *) 35 other_repos : (string * string list) list; 36 (** Repos I don't have: (repo_name, list of handles who have it) *) 37} 38(** Summary of all cross-user comparisons. *) 39 40(** {1 Pretty Printing} *) 41 42val pp_relationship : relationship Fmt.t 43(** [pp_relationship] formats a relationship. *) 44 45val pp_subtree_info : subtree_info Fmt.t 46(** [pp_subtree_info] formats subtree info (shows commit SHA). *) 47 48val pp_repo_comparison : repo_comparison Fmt.t 49(** [pp_repo_comparison] formats a single repo comparison. *) 50 51val pp : t Fmt.t 52(** [pp] formats the full cross-user status with commit SHAs. *) 53 54val pp_summary : t Fmt.t 55(** [pp_summary] formats a succinct summary with emphasis on repos where others 56 have commits not in mine. *) 57 58val is_actionable : relationship -> bool 59(** [is_actionable rel] returns [true] if the relationship indicates that others 60 have commits I should consider pulling (I_am_behind or Diverged). *) 61 62(** {1 Computation} *) 63 64val compute : 65 proc:_ Eio.Process.mgr -> 66 fs:Eio.Fs.dir_ty Eio.Path.t -> 67 verse_config:Verse_config.t -> 68 monopam_config:Config.t -> 69 unit -> 70 t 71(** [compute ~proc ~fs ~verse_config ~monopam_config ()] computes cross-user 72 status by comparing subtrees in my monorepo against all tracked verse 73 members' monorepos. 74 75 For repos that exist in multiple monorepos, determines the relationship 76 between commits (same, ahead, behind, or diverged). 77 78 Uses the checkout in [src/] as the reference for commit comparison when 79 available. 80 81 @param proc Eio process manager 82 @param fs Eio filesystem 83 @param verse_config Verse workspace configuration 84 @param monopam_config Monopam configuration (for checkout paths) *)