Adjust Git_kv.commit to report staging status #8

Merged
hannes merged 1 commit from add-commit into main 2024-11-28 12:48:38 +00:00
2 changed files with 11 additions and 3 deletions
Showing only changes of commit 3276c90b08 - Show all commits

View file

@ -109,7 +109,13 @@ let connect ctx endpoint =
let branch t = t.branch
let commit t = t.head
let commit t =
match t.head, t.committed with
| None, _ -> None
| Some commit, None -> Some (`Clean commit)
| Some commit, Some _ ->
(* XXX: this is not precise as we can have made zero changes *)
Some (`Dirty commit)
type key = Mirage_kv.Key.t

View file

@ -43,8 +43,10 @@ val connect : Mimic.ctx -> string -> t Lwt.t
val branch : t -> Git.Reference.t
(** [branch t] returns the branch used by the given [t]. *)
val commit : t -> Digestif.SHA1.t option
(** [commit t] returns the commit used by the given [t]. *)
val commit : t -> [ `Clean of Digestif.SHA1.t | `Dirty of Digestif.SHA1.t ] option
(** [commit t] returns the commit used by the given [t]. The commit is either
marked [`Dirty _] if we're inside a [change_and_push] or [`Clean _]
otherwise. *)
val to_octets : ?level:int -> t -> string Lwt_stream.t
(** [to_octets ?level store] returns a serialized version of the given [store].