From 4dc3424cb2242c77e2fff7a8b292ccba36653f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= Date: Wed, 13 Jan 2021 22:13:45 +0100 Subject: [PATCH] Switch to ocaml-git v3.0.0 --- plotkicadsch.opam | 2 +- plotkicadsch/src/gitFs.ml | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/plotkicadsch.opam b/plotkicadsch.opam index 8bd7849..5195f7a 100644 --- a/plotkicadsch.opam +++ b/plotkicadsch.opam @@ -24,7 +24,7 @@ depends: [ "lwt" "lwt_ppx" {build} "sha" - "git" {>= "2.0.0"} + "git" {>= "3.0.0"} "git-unix" "base64" {>= "3.0.0"} "cmdliner" diff --git a/plotkicadsch/src/gitFs.ml b/plotkicadsch/src/gitFs.ml index 03dbf93..c689e5c 100644 --- a/plotkicadsch/src/gitFs.ml +++ b/plotkicadsch/src/gitFs.ml @@ -6,8 +6,7 @@ exception InternalGitError of string let make commitish = ( module struct open Git_unix - module Search = Git.Search.Make (Store) - + module Search = Git.Search.Make (Digestif.SHA1) (Store) let rev_parse r = SysAbst.pread "git" [|"rev-parse"; r ^ "^{commit}"|] >>= fun s -> @@ -71,22 +70,22 @@ let make commitish = let get_content filename = with_path filename - @@ function - | Store.Value.Blob b -> + @@ fun res -> match res with + | Git.Value.Blob b -> Lwt.return (Store.Value.Blob.to_string b) | _ -> Lwt.fail (InternalGitError "not a valid path") - let find_file_local filter t = - let open Store.Value.Tree in + let find_file_local filter (t: Store.Value.Tree.t) = + let open Git.Tree in to_list t - |> List.filter_map ~f:(fun {name; node; _} -> - if filter name then Some ([name], Store.Hash.to_hex node) else None + |> List.filter_map ~f:(fun t -> let {node; name; _} = t in + if filter name then Some ([name], Store.Hash.to_hex node) else None ) ;; let find_dir_local t = - let open Store.Value.Tree in + let open Git.Tree in to_list t |> List.filter ~f:(fun {perm;_} -> perm == `Dir) ;; @@ -99,12 +98,12 @@ let make commitish = let path_file_list = List.map local_file_list ~f:(fun (name, hash) -> ((rename name), hash)) in let dirs = find_dir_local node in let%lwt t = fs in - let open Store.Value.Tree in + let open Git.Tree in let recurse_tree = fun entry -> let%lwt res = Store.read t entry.node in match res with |Error e -> Lwt.fail (InternalGitError (Fmt.strf "%a" Store.pp_error e)) - |Ok Store.Value.Tree t ->( + |Ok Git.Value.Tree t ->( let%lwt subdir = recurse_dir ~dirname:entry.name t pattern in let subdir_files = List.map ~f:(fun (name, hash) -> ((rename name), hash)) subdir in Lwt.return subdir_files) @@ -116,7 +115,7 @@ let make commitish = let list_files_from path pattern = with_path path @@ function - | Store.Value.Tree t -> recurse_dir t pattern + | Git.Value.Tree t -> recurse_dir t pattern | _ -> Lwt.fail (InternalGitError "not a tree!") let list_files pattern =list_files_from [] pattern