last_modified: don't find_blob; find the commit! #10

Merged
reynir merged 2 commits from fix-last_modified into main 2024-12-20 12:11:32 +00:00
Showing only changes of commit d2a0e526da - Show all commits

View file

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