Persistent store with Git semantics: lazy reads, delayed writes, content-addressing
1
fork

Configure Feed

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

sbom, runc, cdm, irmin: follow Json.Error.t record shape and plain to_string

- sbom error_of_json_error: Loc.Error.t is now a record { ctx; meta; kind },
not a tuple. Destructure via e.meta.
- sbom, runc, cdm: Json.to_string returns plain string (not result);
collapse the stale 'match ... with | Ok s -> ... | Error _ -> ...' patterns.
- runc of_json: convert Json.Error.t -> string at the mli boundary with
Result.map_error Json.Error.to_string (drops the no-op '| Ok t -> Ok t |
Error e -> Error e' passthrough).
- cdm: wrap Json.Error.t with Json.Error.to_string at the Parse_error
constructor.
- irmin/toml: Toml.Value.Table / Array / String carry 'a Loc.node wrappers
now (tuple with Meta.t); reconstruct them explicitly.
- irmin/admin: Toml.Value matches use (values, meta) pairs and
(string * Meta.t) keys — introduce [assoc_unmeta] helper.

+27 -21
+11 -6
lib/admin/irmin_admin.ml
··· 4 4 5 5 let empty = { allow_emails = [] } 6 6 7 + let assoc_unmeta key fields = 8 + List.find_map 9 + (fun ((k, _), v) -> if String.equal k key then Some v else None) 10 + fields 11 + 7 12 let parse text = 8 13 match Toml.of_string Toml.value text with 9 14 | Error _ -> empty 10 - | Ok (Toml.Value.Table fields) -> ( 11 - match List.assoc_opt "allow" fields with 12 - | Some (Toml.Value.Array entries) -> 15 + | Ok (Toml.Value.Table (fields, _)) -> ( 16 + match assoc_unmeta "allow" fields with 17 + | Some (Toml.Value.Array (entries, _)) -> 13 18 let emails = 14 19 List.filter_map 15 20 (function 16 - | Toml.Value.Table kvs -> ( 17 - match List.assoc_opt "email" kvs with 18 - | Some (Toml.Value.String s) -> Some s 21 + | Toml.Value.Table (kvs, _) -> ( 22 + match assoc_unmeta "email" kvs with 23 + | Some (Toml.Value.String (s, _)) -> Some s 19 24 | _ -> None) 20 25 | _ -> None) 21 26 entries
+14 -11
lib/toml/irmin_toml.ml
··· 2 2 3 3 module S = Irmin.SHA256 4 4 5 + let meta = Toml.Meta.none 6 + 5 7 (* Round-trip a single TOML value through its string form, keyed "_" at the 6 8 top so we can re-parse it as a stand-alone document. *) 7 9 let enc (v : Toml.Value.t) : string = ··· 9 11 | Toml.Value.Table _ -> Toml.to_string Toml.value v 10 12 | _ -> 11 13 (* Scalars and arrays need to be wrapped; use a dummy key. *) 12 - Toml.to_string Toml.value (Toml.Value.Table [ ("_", v) ]) 14 + let wrapped = Toml.Value.Table ([ (("_", meta), v) ], meta) in 15 + Toml.to_string Toml.value wrapped 13 16 14 17 let dec (s : string) : Toml.Value.t = 15 18 match Toml.of_string Toml.value s with 16 - | Ok (Toml.Value.Table [ ("_", v) ]) -> v 19 + | Ok (Toml.Value.Table ([ ((_, _), v) ], _)) -> v 17 20 | Ok v -> v 18 - | Error _ -> Toml.Value.Table [] 21 + | Error _ -> Toml.Value.Table ([], meta) 19 22 20 23 let parse : S.dec = 21 24 fun block -> 22 25 match dec block with 23 - | Toml.Value.Table pairs -> 24 - S.Named (List.map (fun (k, v) -> (k, `Inline (enc v))) pairs) 25 - | Toml.Value.Array items -> 26 + | Toml.Value.Table (pairs, _) -> 27 + S.Named (List.map (fun ((k, _), v) -> (k, `Inline (enc v))) pairs) 28 + | Toml.Value.Array (items, _) -> 26 29 S.Indexed 27 30 (Array.of_list (List.map (fun v -> (`Inline (enc v) : S.child)) items)) 28 31 | _ -> S.Named [] ··· 35 38 let v = 36 39 match child with 37 40 | `Inline data -> dec data 38 - | `Link _ -> Toml.Value.Table [] 41 + | `Link _ -> Toml.Value.Table ([], meta) 39 42 in 40 - (name, v)) 43 + ((name, meta), v)) 41 44 children 42 45 in 43 - enc (Toml.Value.Table pairs) 46 + enc (Toml.Value.Table (pairs, meta)) 44 47 | S.Indexed children -> 45 48 let items = 46 49 Array.to_list ··· 48 51 (fun child -> 49 52 match child with 50 53 | `Inline data -> dec data 51 - | `Link _ -> Toml.Value.Table []) 54 + | `Link _ -> Toml.Value.Table ([], meta)) 52 55 children) 53 56 in 54 - enc (Toml.Value.Array items) 57 + enc (Toml.Value.Array (items, meta)) 55 58 56 59 let ( => ) = S.( => ) 57 60
+2 -4
lib/worktree.ml
··· 47 47 List.iter 48 48 (fun e -> 49 49 Buffer.add_string buf 50 - (Fmt.str "%s\t%s\t%.6f\t%d\n" e.path (H.to_hex e.hash) e.mtime 51 - e.size)) 50 + (Fmt.str "%s\t%s\t%.6f\t%d\n" e.path (H.to_hex e.hash) e.mtime e.size)) 52 51 entries; 53 52 Eio.Path.save ~create:(`Or_truncate 0o644) p (Buffer.contents buf) 54 53 ··· 197 196 let tree_str = 198 197 String.concat "\n" 199 198 (List.map 200 - (fun e -> 201 - Fmt.str "%s\t%s" e.path (H.to_hex e.hash)) 199 + (fun e -> Fmt.str "%s\t%s" e.path (H.to_hex e.hash)) 202 200 new_entries) 203 201 in 204 202 let tree_hash = H.hash_string tree_str in