mirage / ocaml-git

Pure OCaml Git format and protocol
ISC License
363 stars 70 forks source link

Failure "Report status.input: unpack-status" on Sync.push #154

Closed Armael closed 6 years ago

Armael commented 8 years ago

Steps to reproduce:

open Lwt.Infix
open Git
open Git_unix

module Store = FS
module Sync = Sync.Make(Store)
module Search = Git.Search.Make(Store)

let local_repo_location = "/tmp/test"
let repo_uri = Git.Gri.of_string "git@github.com:foo/test"
let file = "README"
let user : Git.User.t = User.{
  name = "user";
  email = "user@foo.bar";
  date = (0L, None);
}

let write_data store msg data =
  Store.read_reference_exn store Reference.master >>= fun head_hash ->
  Store.read_exn store head_hash >>= function
  | Value.Commit head ->
    Store.read_exn store (Hash.of_tree head.Commit.tree) >>= (function
    | Value.Tree old_tree ->
      let new_blob = Value.Blob (Blob.of_raw data) in
      Store.write store new_blob >>= fun new_blob_hash ->
      let new_tree = Value.Tree [
          Tree.{perm = `Normal; name = file; node = new_blob_hash}
        ] in
      Store.write store new_tree >>= fun new_tree_hash ->
      let new_commit = Value.Commit (Commit.{
        tree = Hash.to_tree new_tree_hash;
        parents = [Hash.to_commit head_hash];
        author = user;
        committer = user;
        message = msg;
      }) in
      Store.write store new_commit >>= fun new_commit_hash ->
      Store.write_reference store Reference.master new_commit_hash
    | _ -> failwith "not a valid tree")
  | _ -> failwith "not a valid commit"

let store : Store.t Lwt.t =
  Store.create ~root:local_repo_location () >>= fun store ->
  Sync.clone store ~checkout:false repo_uri >>= fun _ ->
  Lwt.return store

let _ = Lwt_main.run (
    store >>= fun store ->
    write_data store "commit msg" "some contents" >>= fun () ->
    Sync.push store ~branch:Reference.master repo_uri
  )
dinosaure commented 6 years ago

If it's possible to retry your code with the last version of ocaml-git.

samoht commented 6 years ago

Closing, please re-open if you still have the issue with ocaml-git 2.0