A monorepo management tool for the agentic ages
at main 63 lines 2.3 kB view raw
1(** Vendor cache - a persistent bare git repository for caching upstream fetches. 2 3 The cache stores fetched repositories as remotes/branches, allowing multiple 4 unpac projects to share fetched content without re-downloading. *) 5 6(** {1 Types} *) 7 8type t = Eio.Fs.dir_ty Eio.Path.t 9(** Path to the cache bare repository *) 10 11(** {1 Cache Location} *) 12 13val default_path : unit -> string 14(** Returns the default cache path (XDG_CACHE_HOME/unpac/vendor-cache) *) 15 16(** {1 Initialization} *) 17 18val init : proc_mgr:Git.proc_mgr -> fs:Eio.Fs.dir_ty Eio.Path.t -> ?path:string -> unit -> t 19(** [init ~proc_mgr ~fs ?path ()] initializes and returns the cache. 20 Creates the bare repository if it doesn't exist. 21 @param path Optional custom cache path. Uses default if not provided. *) 22 23(** {1 Remote Naming} *) 24 25val url_to_remote_name : string -> string 26(** [url_to_remote_name url] converts a git URL to a remote name. 27 e.g., "https://github.com/dbuenzli/astring.git" -> "github.com/dbuenzli/astring" *) 28 29val branch_name : remote:string -> branch:string -> string 30(** [branch_name ~remote ~branch] returns the full branch name in cache. *) 31 32(** {1 Cache Operations} *) 33 34val has_remote : proc_mgr:Git.proc_mgr -> t -> string -> bool 35(** [has_remote ~proc_mgr cache name] checks if a remote exists in cache. *) 36 37val ensure_remote : proc_mgr:Git.proc_mgr -> t -> url:string -> string 38(** [ensure_remote ~proc_mgr cache ~url] adds remote if needed, returns remote name. *) 39 40val fetch : proc_mgr:Git.proc_mgr -> t -> url:string -> string 41(** [fetch ~proc_mgr cache ~url] fetches from URL into cache, returns remote name. *) 42 43val get_ref : proc_mgr:Git.proc_mgr -> t -> url:string -> branch:string -> string option 44(** [get_ref ~proc_mgr cache ~url ~branch] returns the SHA for a cached ref. *) 45 46val fetch_to_project : 47 proc_mgr:Git.proc_mgr -> 48 cache:t -> 49 project_git:Eio.Fs.dir_ty Eio.Path.t -> 50 url:string -> 51 branch:string -> 52 string 53(** [fetch_to_project ~proc_mgr ~cache ~project_git ~url ~branch] 54 fetches from upstream to cache, then from cache to project's bare repo. 55 Returns the cache ref name. *) 56 57(** {1 Listing} *) 58 59val list_remotes : proc_mgr:Git.proc_mgr -> t -> string list 60(** List all remotes in the cache. *) 61 62val list_branches : proc_mgr:Git.proc_mgr -> t -> string list 63(** List all branches in the cache. *)