在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:mirage/ocaml-git开源软件地址:https://github.com/mirage/ocaml-git开源编程语言:OCaml 99.1%开源软件介绍:ocaml-git -- Git format and protocol in pure OCamlSupport for on-disk and in-memory Git stores. Can read and write all the Git
objects: blobs, trees, commits and tags. It can also handle pack files, pack
indexes and index files (where the staging area lives - only for All the objects share a consistent API, and convenience functions are provided to manipulate the different objects. For instance, it is possible to make a pack file position independent (as the Zlib compression might change the relative offsets between the packed objects), to generate pack indexes from pack files, or to expand the filesystem of a given commit. The library comes with some command-line tools called
As a MirageOS project, The API documentation is available online. Build, Install Instructions and PackagesTo build and install the project, simply run: $ opam install git
$ opam install git-unix
$ opam install git-mirage Linking-trick
These libraries provide a C implementation and an OCaml implementation (mostly
to be compatible with These libraries use virtual-library available with What is supported
What is not supported
PerformancePerformance is comparable to the Git tool. ExampleThis # ;; load necessary modules
# #require "checkseum.c" ;;
# #require "digestif.c" ;;
# #require "git-unix" ;;
# ;; we are going to use this project's local repository
# module Store = Git_unix.Store ;;
module Store = Git_unix.Store
# ;; this module is useful for finding git objects in a git store
# module Search = Git.Search.Make (Digestif.SHA1) (Store) ;;
module Search :
sig
type hash = Store.hash
type store = Store.t
type pred =
[ `Commit of hash
| `Tag of string * hash
| `Tree of string * hash
| `Tree_root of hash ]
val pred : store -> ?full:bool -> hash -> pred list Lwt.t
type path =
[ `Commit of path | `Path of string list | `Tag of string * path ]
val mem : store -> hash -> path -> bool Lwt.t
val find : store -> hash -> path -> hash option Lwt.t
end
# ;; we want to read the contents of a blob under name [filename]
# let read filename =
let open Lwt_result.Syntax in
(* get store located in current root's .git folder *)
let* store = Store.v (Fpath.v (Sys.getcwd ())) in
(* find obj-id pointed at by master branch (reference) *)
let* commit_id = Store.Ref.resolve store Git.Reference.master in
let open Lwt.Syntax in
(* find obj-id of of [filename] as a git blob *)
let* blob_id = Search.find store commit_id (`Commit (`Path [ filename ])) in
match blob_id with
| None -> Lwt.return (Error (`Not_found commit_id))
| Some hash ->
(* read contents of the blob *)
Store.read store hash
;;
val read : string -> (Store.Value.t, Store.error) Lwt_result.t = <fun>
# let pp =
let ok ppf = function
| Git.Value.Blob b -> Fmt.string ppf (Git.Blob.to_string b)
| _ -> Fmt.string ppf "#git-object"
in
Fmt.result ~ok ~error:Store.pp_error;;
val pp : ('_weak1 Git.Value.t, Store.error) result Fmt.t = <fun>
# Lwt_main.run Lwt.Infix.(read "README.md" >|= pp Fmt.stdout) ;;
ocaml-git -- Git format and protocol in pure OCaml
Support for on-disk and in-memory Git stores. Can read and write all
the Git objects: the usual blobs, trees, commits and tags but also
the pack files, pack indexes and the index file (where the staging area
lives).
[...] () LicenseMIT, see LICENSE.md file for its text. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论