Pure MoonBit Git implementation
Dependencies
pub(open) trait HttpClient {
get(Self, String, Map[String, String]) -> (HttpResponse, Bytes) raise GitError
post(Self, String, Bytes, Map[String, String]) -> (HttpResponse, Bytes) raise GitError
}pub(all) suberror GitError {
InvalidObject(String)
HashMismatch(String, String)
PackfileError(String)
ProtocolError(String)
IoError(String)
}pub(all) enum FilterSpec {
NoFilter
BlobNone
BlobLimit(Int64)
TreeDepth(Int)
}impl HttpClient for MockHttpClientfn get(self : MockHttpClient, url : String, _headers : Map[String, String]) -> (HttpResponse, Bytes) raise GitErrorfn post(self : MockHttpClient, url : String, _body : Bytes, _headers : Map[String, String]) -> (HttpResponse, Bytes) raise GitErrorfn MockHttpClient::add_response(self : MockHttpClient, url : String, code : Int, body : Bytes) -> Unitpub struct NativeHttpClient {
dummy : Int
}pub struct ObjectId {
bytes : FixedArray[Byte]
}pub(all) enum ObjectType {
Blob
Tree
Commit
Tag
}pub(all) enum PackDeltaMode {
NoDelta
RefDelta
OfsDelta
}fn PackObject::with_metadata(obj_type : ObjectType, data : Bytes, id : ObjectId, offset : Int, crc32 : UInt) -> PackObjectpub(all) enum ProtocolVersion {
V0
V2
}impl Eq for ProtocolVersionfn PushRequest::new(old_id : ObjectId, new_id : ObjectId, refname : String, packfile : Bytes) -> PushRequestpub struct Remote {
url : String
}pub struct RemoteSpec {
kind : RemoteKind
raw : String
host : String?
path : String
base_url : String?
}pub struct Sha1State {
h : FixedArray[Int]
block : FixedArray[Byte]
w : FixedArray[Int]
block_len : Int
total_len : Int64
}impl FileSystem for TestFsimpl RepoFileSystem for TestFsfn build_fetch_request_v2(agent : String, wants : Array[ObjectId], depth : Int, filter? : FilterSpec) -> Bytesfn checkout_commit_to_fs(store : ObjectStore, commit_id : ObjectId, fs : &FileSystem, root : String) -> Unit raise GitErrorasync fn clone_http(remote : String, prefer_v2 : Bool, depth? : Int, filter? : FilterSpec) -> (Array[(ObjectId, String)], Array[PackObject]) raise GitErrorasync fn clone_http_to_fs(remote : String, prefer_v2 : Bool, fs : &FileSystem, root : String, depth? : Int, filter? : FilterSpec) -> Array[(ObjectId, String)] raise GitErrorasync fn clone_process(remote : String, prefer_v2 : Bool) -> (Array[(ObjectId, String)], Array[PackObject]) raise GitErrorasync fn clone_process_to_fs(remote : String, prefer_v2 : Bool, fs : &FileSystem, root : String) -> Array[(ObjectId, String)] raise GitErrorasync fn clone_remote(remote : String, prefer_v2 : Bool) -> (Array[(ObjectId, String)], Array[PackObject]) raise GitErrorasync fn clone_remote_to_fs(remote : String, prefer_v2 : Bool, fs : &FileSystem, root : String) -> Array[(ObjectId, String)] raise GitErrorasync fn clone_to_fs_with_http(remote : String, prefer_v2 : Bool, depth : Int, filter : FilterSpec, fs : &FileSystem, root : String, http_get : async (String, Map[String, String]) -> (HttpResponse, Bytes) raise GitError, http_post : async (String, Bytes, Map[String, String]) -> (HttpResponse, Bytes) raise GitError) -> Array[(ObjectId, String)] raise GitErrorasync fn clone_with_http(remote : String, prefer_v2 : Bool, depth : Int, filter : FilterSpec, http_get : async (String, Map[String, String]) -> (HttpResponse, Bytes) raise GitError, http_post : async (String, Bytes, Map[String, String]) -> (HttpResponse, Bytes) raise GitError) -> (Array[(ObjectId, String)], Array[PackObject]) raise GitErrorfn create_blob_packfile(content : Bytes) -> Bytesfn create_packfile_with_delta_stats(objects : Array[PackObject], delta_mode : PackDeltaMode) -> (Bytes, Int)async fn discover_upload_refs_with_http(remote : String, prefer_v2 : Bool, http_get : async (String, Map[String, String]) -> (HttpResponse, Bytes) raise GitError, http_post : async (String, Bytes, Map[String, String]) -> (HttpResponse, Bytes) raise GitError) -> (Array[(ObjectId, String)], Array[String], ProtocolVersion, Map[String, String]) raise GitErrorasync fn fetch_objects(remote : String, wants : Array[ObjectId], prefer_v2 : Bool) -> Array[PackObject] raise GitErrorasync fn fetch_objects_http(remote : String, wants : Array[ObjectId], prefer_v2 : Bool, depth? : Int, filter? : FilterSpec) -> Array[PackObject] raise GitErrorasync fn fetch_objects_process(remote : String, wants : Array[ObjectId], prefer_v2 : Bool) -> Array[PackObject] raise GitErrorasync fn fetch_objects_with_http(remote : String, wants : Array[ObjectId], prefer_v2 : Bool, depth : Int, filter : FilterSpec, http_get : async (String, Map[String, String]) -> (HttpResponse, Bytes) raise GitError, http_post : async (String, Bytes, Map[String, String]) -> (HttpResponse, Bytes) raise GitError) -> Array[PackObject] raise GitErrorasync fn fetch_pack_http(remote : String, wants : Array[ObjectId], prefer_v2 : Bool, depth? : Int, filter? : FilterSpec) -> Bytes raise GitErrorasync fn fetch_pack_with_http(remote : String, wants : Array[ObjectId], prefer_v2 : Bool, depth : Int, filter : FilterSpec, http_get : async (String, Map[String, String]) -> (HttpResponse, Bytes) raise GitError, http_post : async (String, Bytes, Map[String, String]) -> (HttpResponse, Bytes) raise GitError) -> Bytes raise GitErrorfn materialize_clone_to_fs(store : ObjectStore, commit_id : ObjectId, refname : String, remote_url : String, fs : &FileSystem, root : String) -> Unit raise GitErrorasync fn native_http_get(url : String, headers : Map[String, String]) -> (HttpResponse, Bytes) raise GitErrorasync fn native_http_post(url : String, body : Bytes, headers : Map[String, String]) -> (HttpResponse, Bytes) raise GitErrorfn parse_packfile_stream_with_bases(data : Bytes, bases : Array[PackObject], emit : (PackObject) -> Unit) -> Unit raise GitErrorfn parse_packfile_with_bases(data : Bytes, bases : Array[PackObject]) -> Array[PackObject] raise GitErrorfn pktline_encode(data : String) -> Bytesasync fn push_with_http(remote : Remote, req : PushRequest, http_get : async (String, Map[String, String]) -> (HttpResponse, Bytes) raise GitError, http_post : async (String, Bytes, Map[String, String]) -> (HttpResponse, Bytes) raise GitError) -> String raise GitErrorasync fn upload_pack_info_refs_with_http(remote : String, prefer_v2 : Bool, http_get : async (String, Map[String, String]) -> (HttpResponse, Bytes) raise GitError) -> Bytes raise GitErrorasync fn upload_pack_request(remote : String, body : Bytes, prefer_v2 : Bool) -> Bytes raise GitErrorasync fn upload_pack_request_http(remote : String, body : Bytes, prefer_v2 : Bool) -> Bytes raise GitErrorasync fn upload_pack_request_process(remote : String, body : Bytes, prefer_v2 : Bool) -> Bytes raise GitErrorasync fn upload_pack_request_with_http(remote : String, body : Bytes, prefer_v2 : Bool, http_post : async (String, Bytes, Map[String, String]) -> (HttpResponse, Bytes) raise GitError) -> Bytes raise GitErrorfn write_git_metadata(store : ObjectStore, commit_id : ObjectId, refname : String, remote_url : String, fs : &FileSystem, root : String) -> Unit raise GitErrorfn write_pack_index_from_objects(fs : &FileSystem, idx_path : String, pack : Bytes, objects : Array[PackObject]) -> Unit raise GitErrorfn write_pack_index_from_objects_versioned(fs : &FileSystem, idx_path : String, pack : Bytes, objects : Array[PackObject], version : Int) -> Unit raise GitErrorfn write_packfile_with_index(fs : &FileSystem, git_dir : String, pack : Bytes, objects : Array[PackObject]) -> Unit raise GitErrorPure MoonBit Git implementation
Dependencies