Compare commits

..

No commits in common. "aec833f991fbccf93b95c9daba3836922ad1f634" and "a6ebf32529650236fa2879e88b52880335c291d7" have entirely different histories.

View file

@ -463,36 +463,33 @@ module Make (Pclock : Mirage_clock.PCLOCK) = struct
let last_modified t key = let last_modified t key =
let open Lwt.Infix in let open Lwt.Infix in
match t.committed, t.head with find_blob t key >>=
| None, None -> Option.fold
Lwt.return (Error (`Not_found key)) ~none:(Lwt.return (Error (`Not_found key)))
| Some _, _ -> ~some:(fun head ->
Lwt.return_ok Store.read_exn t.store head >|= function
(Option.fold | Commit c ->
~none:Ptime.epoch let author = Git_commit.author c in
~some:Fun.id (Ptime.of_float_s (Int64.to_float (now ())))) let secs, tz_offset = author.Git.User.date in
| None, Some head -> let secs =
(* See https://github.com/ocaml/ocaml/issues/9301 why we have the Option.fold ~none:secs
intermediate [r] value. *) ~some:(fun { Git.User.sign ; hours ; minutes } ->
let+ r = Store.read_exn t.store head in let tz_off = Int64.(mul (add (mul (of_int hours) 60L) (of_int minutes)) 60L) in
let[@warning "-8"] Commit c = r in match sign with
let author = Git_commit.author c in | `Plus -> Int64.(sub secs tz_off)
let secs, tz_offset = author.Git.User.date in | `Minus -> Int64.(add secs tz_off))
let secs = tz_offset
Option.fold ~none:secs in
~some:(fun { Git.User.sign ; hours ; minutes } -> let ts =
let tz_off = Int64.(mul (add (mul (of_int hours) 60L) (of_int minutes)) 60L) in Option.fold
match sign with ~none:Ptime.epoch
| `Plus -> Int64.(sub secs tz_off) ~some:Fun.id (Ptime.of_float_s (Int64.to_float secs))
| `Minus -> Int64.(add secs tz_off)) in
tz_offset Ok ts
in | _ ->
let ts = Ok (Option.fold
Option.fold ~none:Ptime.epoch
~none:Ptime.epoch ~some:Fun.id (Ptime.of_float_s (Int64.to_float (now ())))))
~some:Fun.id (Ptime.of_float_s (Int64.to_float secs))
in
Ok ts
let digest t key = let digest t key =
let open Lwt.Infix in let open Lwt.Infix in