Homebrew bottle builder and tap manager for OCaml monorepos
0
fork

Configure Feed

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

ocaml-claude: rename err.ml to error.ml

+63 -1
+47
lib/homebrew.ml
··· 280 280 lines := replace_version ~version !lines; 281 281 Bos.OS.File.write (Fpath.v path) (String.concat "\n" !lines) 282 282 |> Result.map_error (fun (`Msg e) -> e) 283 + 284 + (* Extract the [desc "..."] string from a line. Accepts leading whitespace 285 + and either double or single quotes. Returns [None] if the line is not a 286 + [desc] declaration or the quote pair is malformed. *) 287 + let desc_of_line line = 288 + let s = Astring.String.trim line in 289 + if not (Astring.String.is_prefix ~affix:"desc" s) then None 290 + else 291 + let rest = Astring.String.with_range ~first:4 s |> Astring.String.trim in 292 + let len = String.length rest in 293 + if len < 2 then None 294 + else 295 + let q = rest.[0] in 296 + if q <> '"' && q <> '\'' then None 297 + else 298 + match 299 + String.index_opt (Astring.String.with_range ~first:1 rest) q 300 + with 301 + | None -> None 302 + | Some i -> Some (String.sub rest 1 i) 303 + 304 + let desc_of_file ~path = 305 + match Bos.OS.File.read (Fpath.v path) with 306 + | Error _ -> None 307 + | Ok content -> 308 + Astring.String.cuts ~sep:"\n" content |> List.find_map desc_of_line 283 309 end 284 310 285 311 module Tap = struct ··· 377 403 in 378 404 Log.info (fun m -> m "Tap pushed successfully."); 379 405 Ok () 406 + 407 + let reset_to_remote ~local_path = 408 + let open Result in 409 + let ( let* ) = bind in 410 + let* _ = 411 + Bos.OS.Cmd.run 412 + Bos.Cmd.(v "git" % "-C" % local_path % "fetch" % "origin" % "main") 413 + |> Result.map_error (fun (`Msg e) -> e) 414 + in 415 + let* _ = 416 + Bos.OS.Cmd.run 417 + Bos.Cmd.( 418 + v "git" % "-C" % local_path % "reset" % "--hard" % "origin/main") 419 + |> Result.map_error (fun (`Msg e) -> e) 420 + in 421 + let* _ = 422 + Bos.OS.Cmd.run Bos.Cmd.(v "git" % "-C" % local_path % "clean" % "-fdx") 423 + |> Result.map_error (fun (`Msg e) -> e) 424 + in 425 + Log.info (fun m -> m "Tap reset to origin/main."); 426 + Ok () 380 427 end
+16 -1
lib/homebrew.mli
··· 100 100 URLs and SHA256 lines inside the formula file at [path]. Each tuple is 101 101 [(platform, new_url, sha256_hex)]. Also updates the [version] declaration. 102 102 Non-destructive for other content. *) 103 + 104 + val desc_of_file : path:string -> string option 105 + (** [desc_of_file ~path] reads the [desc "..."] string from an existing 106 + formula file. Returns [None] when the file cannot be read or has no [desc] 107 + line. Useful for building summary listings (e.g. a tap README) over 108 + formulas that were generated by different sources. *) 103 109 end 104 110 105 111 (** {1 Tap repositories} *) ··· 119 125 val commit_and_push : 120 126 local_path:string -> message:string -> (unit, string) result 121 127 (** Stage all changes, commit with [message], and push. No-op if the tree is 122 - clean. *) 128 + clean. Returns an error (carrying git's message) on non-fast-forward 129 + rejection; the caller should reset with {!reset_to_remote}, regenerate the 130 + tap's content, and retry. *) 131 + 132 + val reset_to_remote : local_path:string -> (unit, string) result 133 + (** Fetch and hard-reset the tap checkout to [origin/main], discarding any 134 + local commits, staged changes, and working-tree modifications. Intended 135 + for retry loops in tap-update flows, where the local state is fully 136 + regenerated from the remote plus a fresh set of bottles — the only work 137 + being discarded is a failed attempt at the same generated content. *) 123 138 end