forked from
gazagnaire.org/irmin
Persistent store with Git semantics: lazy reads, delayed writes, content-addressing
1(** Del command. *)
2
3let run ~repo ~branch ~message path =
4 let message = match message with Some m -> m | None -> "Delete " ^ path in
5 let config = Config.load ~repo () in
6 let (module B : Common.BACKEND) = Common.backend_of_config config in
7 Eio_main.run @@ fun env ->
8 let fs = Eio.Stdenv.cwd env in
9 Eio.Switch.run @@ fun sw ->
10 let store = B.open_store ~sw ~fs ~config in
11 match B.checkout store ~branch with
12 | None ->
13 Common.error "Branch %a not found" Common.styled_cyan branch;
14 1
15 | Some tree ->
16 let tree = B.tree_remove tree (Common.path_of_string path) in
17 let parents =
18 match B.head store ~branch with None -> [] | Some h -> [ h ]
19 in
20 let hash =
21 B.commit store ~tree ~parents ~message ~author:"irmin <irmin@local>"
22 in
23 B.set_head store ~branch hash;
24 Common.success "%a" Common.styled_faint (B.hash_short hash);
25 0