pandonetwork / pando

A distributed remote protocol for git based on IPFS, ethereum and aragonOS
184 stars 14 forks source link

pando.js #50

Open osarrouy opened 5 years ago

osarrouy commented 5 years ago

Hey,

Here is a summary of the discussion we've had yesterday with Cory regarding the implementation of a small pando.js library.

What

The goal of this library would be to:

How

To do so, we need to implement a small library providing the following features:

Details

js-git-ipld commit objects look like that:

{
  "author": {
    "date": "1503667703 +0200",
    "email": "author@mail",
    "name": "Author Name"
  },
  "committer": {
    "date": "1503667703 +0200",
    "email": "author@mail",
    "name": "Author Name"
  },
  "message": "Commit Message\n",
  "parents": [
    { "/": cid }, { "/": cid }, ...
  ],
  "tree": { "/", cid }
}

The idea would be for this library to take the CID of such a given commit [the HEAD cid of a branch] and turn it into the following ordered array:

[
  commitN,
  commitN-1,
  commitN-2,
  ...
]

Where each commit would look like that:

{
  "cid": zw9X ..., // CID of the commit
  "sha": 9c4v ..., // git sha1 of the commit
  " "author": {
    "date": "1503667703 +0200",
    "email": "author@mail",
    "name": "Author Name"
  },
  "committer": {
    "date": "1503667703 +0200",
    "email": "author@mail",
    "name": "Author Name"
  },
  "message": "Commit Message\n",
  "tree": {
    "README.md": { "lastEdit": { "date": xxx, "message": xxx }, mode: "12600", "blob":  zw9x ... // CID of the file },
    "app/index.js": { "lastEdit": { "date": xxx, "message": xxx }, mode: "12600", "blob":  zw9x ... // CID of the file  },
    "app/util/index.js": { "lastEdit": { "date": xxx, "message": xxx }, mode: "12600", "blob":  zw9x ... // CID of the file },
     ...
  },
  parents: [
    zw9x ..., // CID of parent commit
    zw9x ... // CID of the
    ...
  ]
}

Conversely, this library should be able to take the object described below as an input an turn it back into an IPLD commit.

osarrouy commented 5 years ago

IPLD folks have updated their specs and all their related js implementations. This is a mess now because if we wanna make pando compatible with their new release [and the upcoming ones] we have to update this library, but also the pando-repository frontend and the git-remote-pando CLI.

This makes me think that we clearly have a design issue since all this packages should rely on the same library the we could just update once to update all the packages.

I'm gonna try to figure out a possible interface / architecture for this library in the coming days ...