Coder Social home page Coder Social logo

js-git's Introduction

JS-Git

Gitter

This project is a collection of modules that helps in implementing git powered applications in JavaScript. The original purpose for this is to enable better developer tools for authoring code in restricted environments like ChromeBooks and tablets. It also enables using git as a database to replace SQL and no-SQL data stores in many applications.

This project was initially funded by two crowd-sourced fundraisers. See details in BACKERS.md and BACKERS-2.md. Thanks to all of you who made this possible!

Usage

Detailed API docs are contained in the doc subfolder of this repository.

In general the way you use js-git is you create a JS object and then mixin the functionality you need. Here is an example of creating an in-memory database, creating some objects, and then walking that tree using the high-level walker APIs.

Creating a repo object.

// This provides symbolic names for the octal modes used by git trees.
var modes = require('js-git/lib/modes');

// Create a repo by creating a plain object.
var repo = {};

// This provides an in-memory storage backend that provides the following APIs:
// - saveAs(type, value) => hash
// - loadAs(type, hash) => hash
// - saveRaw(hash, binary) =>
// - loadRaw(hash) => binary
require('js-git/mixins/mem-db')(repo);

// This adds a high-level API for creating multiple git objects by path.
// - createTree(entries) => hash
require('js-git/mixins/create-tree')(repo);

// This provides extra methods for dealing with packfile streams.
// It depends on
// - unpack(packStream, opts) => hashes
// - pack(hashes, opts) => packStream
require('js-git/mixins/pack-ops')(repo);

// This adds in walker algorithms for quickly walking history or a tree.
// - logWalk(ref|hash) => stream<commit>
// - treeWalk(hash) => stream<object>
require('js-git/mixins/walkers')(repo);

// This combines parallel requests for the same resource for efficiency under load.
require('js-git/mixins/read-combiner')(repo);

// This makes the object interface less strict.  See its docs for details
require('js-git/mixins/formats')(repo);

Generators vs Callbacks

There are two control-flow styles that you can use to consume js-git APIs. All the examples here use yield style and assume the code is contained within a generator function that's yielding to a tool like gen-run.

This style requires ES6 generators. This feature is currently in stable Firefox, in stable Chrome behind a user-configurable flag, in node.js 0.11.x or greater with a command-line flag.

Also you can use generators on any ES5 platform if you use a source transform like Facebook's regenerator tool.

You read more about how generators work at Generators vs Fibers.

var run = require('gen-run');

run(function*() {
 // Blocking logic goes here.  You can use yield
 var result = yield someAction(withArgs);
 // The generator pauses at yield and resumes when the data is available.
 // The rest of your process is not blocked, just this generator body.
 // If there was an error, it will throw into this generator.
});

If you can't use this new feature or just plain prefer node-style callbacks, all js-git APIs also support that. The way this works is actually quite simple. If you don't pass in the callback, the function will return a partially applied version of your call expecting just the callback.

someAction(withArgs, function (err, value) {
  if (err) return handleMyError(err);
  // do something with value
});

// The function would be implemented to support both style like this.
function someAction(arg, callback) {
  if (!callback) return someAction.bind(this, arg);
  // We now have callback and arg
}

Basic Object Creation

Now we have an in-memory git repo useful for testing the network operations or just getting to know the available APIs.

In this example, we'll create a blob, create a tree containing that blob, create a commit containing that tree. This shows how to create git objects manually.

  // First we create a blob from a string.  The `formats` mixin allows us to
  // use a string directly instead of having to pass in a binary buffer.
  var blobHash = yield repo.saveAs("blob", "Hello World\n");

  // Now we create a tree that is a folder containing the blob as `greeting.txt`
  var treeHash = yield repo.saveAs("tree", {
    "greeting.txt": { mode: modes.file, hash: blobHash }
  });

  // With that tree, we can create a commit.
  // Again the `formats` mixin allows us to omit details like committer, date,
  // and parents.  It assumes sane defaults for these.
  var commitHash = yield repo.saveAs("commit", {
    author: {
      name: "Tim Caswell",
      email: "[email protected]"
    },
    tree: treeHash,
    message: "Test commit\n"
  });

Basic Object Loading

We can read objects back one at a time using loadAs.

// Reading the file "greeting.txt" from a commit.

// We first read the commit.
var commit = yield repo.loadAs("commit", commitHash);
// We then read the tree using `commit.tree`.
var tree = yield repo.loadAs("tree", commit.tree);
// We then read the file using the entry hash in the tree.
var file = yield repo.loadAs("blob", tree["greeting.txt"].hash);
// file is now a binary buffer.

When using the formats mixin there are two new types for loadAs, they are "text" and "array".

// When you're sure the file contains unicode text, you can load it as text directly.
var fileAsText = yield repo.loadAs("text", blobHash);

// Also if you prefer array format, you can load a directory as an array.
var entries = yield repo.loadAs("array", treeHash);
entries.forEach(function (entry) {
  // entry contains {name, mode, hash}
});

Using Walkers

Now that we have a repo with some minimal data in it, we can query it. Since we included the walkers mixin, we can walk the history as a linear stream or walk the file tree as a depth-first linear stream.

// Create a log stream starting at the commit we just made.
// You could also use symbolic refs like `refs/heads/master` for repos that
// support them.
var logStream = yield repo.logWalk(commitHash);

// Looping through the stream is easy by repeatedly calling waiting on `read`.
var commit, object;
while (commit = yield logStream.read(), commit !== undefined) {

  console.log(commit);

  // We can also loop through all the files of each commit version.
  var treeStream = yield repo.treeWalk(commit.tree);
  while (object = yield treeStream.read(), object !== undefined) {
    console.log(object);
  }

}

Filesystem Style Interface

If you feel that creating a blob, then creating a tree, then creating the parent tree, etc is a lot of work to save just one file, I agree. While writing the tedit app, I discovered a nice high-level abstraction that you can mixin to make this much easier. This is the create-tree mixin referenced in the above config.

// We wish to create a tree that contains `www/index.html` and `README.me` files.
// This will create these two blobs, create a tree for `www` and then create a
// tree for the root containing `README.md` and the newly created `www` tree.
var treeHash = yield repo.createTree({
  "www/index.html": {
    mode: modes.file,
    content: "<h1>Hello</h1>\n<p>This is an HTML page?</p>\n"
  },
  "README.md": {
    mode: modes.file,
    content: "# Sample repo\n\nThis is a sample\n"
  }
});

This is great for creating several files at once, but it can also be used to edit existing trees by adding new files, changing existing files, or deleting existing entries.

var changes = [
  {
    path: "www/index.html" // Leaving out mode means to delete the entry.
  },
  {
    path: "www/app.js", // Create a new file in the existing directory.
    mode: modes.file,
    content: "// this is a js file\n"
  }
];

// We need to use array form and specify the base tree hash as `base`.
changes.base = treeHash;

treeHash = yield repo.createTree(changes);

Creating Composite Filesystems

The real fun begins when you create composite filesystems using git submodules.

The code that handles this is not packaged as a repo mixin since it spans several independent repos. Instead look to the git-tree repo for the code. It's interface is still slightly unstable and undocumented but is used in production by tedit and my node hosting service that complements tedit.

Basically this module allows you to perform high-level filesystem style commands on a virtual filesystem that consists of many js-git repos. Until there are proper docs, you can see how tedit uses it at https://github.com/creationix/tedit-app/blob/master/src/data/fs.js#L11-L21.

Mounting Github Repos

I've been asking Github to enable CORS headers to their HTTPS git servers, but they've refused to do it. This means that a browser can never clone from github because the browser will disallow XHR requests to the domain.

They do, however, offer a REST interface to the raw git data.

Using this I wrote a mixin for js-git that uses github as the backend store.

Code at https://github.com/creationix/js-github. Usage in tedit can be seen at https://github.com/creationix/tedit-app/blob/master/src/data/fs.js#L31.

js-git's People

Contributors

aaronhammond avatar aaronpowell avatar alexbirkett avatar aredridel avatar creationix avatar dfries avatar doublelift avatar dregin avatar dscho avatar ezralalonde avatar funroll avatar gitter-badger avatar jason-cooke avatar kmalakoff avatar kriskowal avatar mintbridge avatar mrscreationix avatar scottgonzalez avatar seriema avatar theknarf avatar tracker1 avatar vsivsi avatar wkonkel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

js-git's Issues

Announce new fund-raising to the Kickstarter group

I wasn't aware of the new fund-raising at BountySource. Naturally I donated at once, but I think it might be an idea to send an email to all the backers on Kickstarter. Just shortly write what was delivered as part of the Kickstarter, and link to this new one (maybe you can't link to a "competitor" Kickstarter, but link to Github then) saying you want to finish this and need more money.

Add proper unit tests for push-to-pull

This is for @neilk

The newly created https://github.com/creationix/push-to-pull package needs some good unit tests.

An example of what I want can be seen in https://github.com/creationix/min-stream/tree/master/test

Use tape and test in browsers and in node. I'll hook it up to travis and testling got CI. You can use @chrisdiskinson's beefy server for the testling tests I think.

push-to-pull needs to test the various combinations:

  • Sync source, async source
  • fast sink, slow sink
  • push-filters that output more than they input, push-filters that output less than they input

after cloning, git can't read index

I successfully cloned one of my repos via https. but running git status in the repo results in a error message like this:

fatal: Unknown index entry format 28dc0000

Because I also have some git prompt addition the error messages come after each command.

$ git --version
git version 1.7.10.4

I installed js-git-node from npm. I cloned http://github.com/Floby/Nigel


Want to back this issue? Place a bounty on it! We accept bounties via Bountysource.

Fill out BACKERS.md

Using the backers report, fill out the BACKERS.md file in the repo. This will require sending out a survey to ask people what name they want to be listed under.

check out chrisdickinson's recent work

how to supply password for my private key?

if i try an ssh key, I get this:

~/c>jsgit clone [email protected]:creationix/js-git.git

Error: Encrypted private key detected, but no passphrase given
    at Connection.connect (/Users/dominictarr/.nave/installed/0.10.10/lib/node_modules/js-git-node/node_modules/js-git-node-platform/node_modules/ssh2/lib/Connection.js:1088:15)
    at module.exports (/Users/dominictarr/.nave/installed/0.10.10/lib/node_modules/js-git-node/node_modules/js-git-node-platform/ssh.js:32:5)
    at connect (/Users/dominictarr/.nave/installed/0.10.10/lib/node_modules/js-git-node/node_modules/js-git/protocols/ssh.js:31:5)
    at discover (/Users/dominictarr/.nave/installed/0.10.10/lib/node_modules/js-git-node/node_modules/js-git/protocols/ssh.js:61:29)
    at Object.fetch (/Users/dominictarr/.nave/installed/0.10.10/lib/node_modules/js-git-node/node_modules/js-git/protocols/ssh.js:70:5)
    at /Users/dominictarr/.nave/installed/0.10.10/lib/node_modules/js-git-node/node_modules/js-git/helpers/parallel-data.js:18:18
    at Array.forEach (native)
    at parallelData (/Users/dominictarr/.nave/installed/0.10.10/lib/node_modules/js-git-node/node_modules/js-git/helpers/parallel-data.js:17:9)
    at Object.<anonymous> (/Users/dominictarr/.nave/installed/0.10.10/lib/node_modules/js-git-node/bin/clone.js:66:1)
    at Module._compile (module.js:456:26)

Want to back this issue? Place a bounty on it! We accept bounties via Bountysource.

Document platform requirements

Would be good to document what platform implementations need to provide, eg.
For bare repos need:

  • sha1
  • inflate
  • deflate
  • object db

then additionally for working dir support also need:

  • fs
  • index db

So for the repo browser app for example, only the bare repo set is needed from the platform.

This repo is too disorganized & confusing

This repo has unfinished code, empty files, old files, etc. etc. It would be great if you could remove everything from this repo and have just a README.md that links to the following...

  1. A Javascript library that is commandline and browser agnostic
  2. A Node CLI wrapper for the Javascript library
  3. A Browser wrapper for the Javascript library

Add proper unit tests for sub-stream

This is for @jeffslofish

The newly created https://github.com/creationix/sub-stream package needs some good unit tests.

An example of what I want can be seen in https://github.com/creationix/min-stream/tree/master/test

Use tape and test in browsers and in node. I'll hook it up to travis and testling got CI. You can use @chrisdiskinson's beefy server for the testling tests I think.

sub-stream needs to test the same various combinations that push-to-pull tests as well as 0-sized, 1-sized, and n-sized nested bodies. Any more tests you can think of to cover extra code paths would be great.

  • Sync source, async source
  • fast sink, slow sink
  • push-filters that output more than they input, push-filters that output less than they input
  • empty body in substream, body with 1 chunk, body with more than one chunk
  • fast and slow consumers of the substreams

Tried using Emscripten?

You're going to be asked this multiple times I suppose, might as well have some place to point them, but have you tried using Emscripten with libgit?

Port git-browser to windows RT

To add a new platform to git-browser, you only need create a new target in the make file and create a new bootstrap file in the src folder. Then add whatever libraries you need to impement this.

The hardest part for me is actually testing the code. I don't know how to use visual studio and I'm often not on a windows computer at all. I do have a Surface RT for testing though if someone wants to help me set up a dev workflow I can use.

Fix broken links when cloning luvit.

tim@touchsmart:~/JSGit/git-node/examples$ node clone.js git://github.com/luvit/luvit.git
Cloning git://github.com/luvit/luvit.git to luvit.git
Counting objects: 8034, done.
Compressing objects: 100% (4216/4216), done.
Total 8034 (delta 4129), reused 7270 (delta 3426)
Receiving objects: 100% (8034/8034)   
Applying deltas: 100% (4129/4129)   
Done
tim@touchsmart:~/JSGit/git-node/examples$ cd luvit.git/
tim@touchsmart:~/JSGit/git-node/examples/luvit.git$ git fsck
Checking object directories: 100% (256/256), done.
broken link from    tree ce5bc0e22c2876b388c5ec011f91fd869fd7dba7
              to    tree 9d18b2f173db4b1473f454bbb1a29c4e19ba0aca
broken link from  commit 12449bf81b3c2b59f113ce960fdc954938105ef7
              to    tree 4df80ea18061bd98481a4b1d3223e4a182febd5e
broken link from  commit 5dfaea433f2ce4bfce126596590393961a698334
              to    tree 80ff534035ebc424b09c7068dbe6928f4f2672cd
broken link from  commit fb2f05e03102d5a57ef7eb263ea497850e425798
              to    tree 2a3c114353dbbb4416a938dc8e1c371998e9e116
broken link from  commit a9c05ba81f6d6268ae95c78da54233d15f089c23
              to    tree dec220f984bd1e218180c24d301ed8d417390bd1
broken link from  commit 8b9f4f029a4cc197be5a28f904f282fd245c7442
              to    tree 38f44bd62fac67a6932d934c68d8971ca142663e
broken link from  commit 52b7010c01233d6a8eb53bf2f734c6db7b73661c
              to    tree 6d025930b3185c7f61dafd673bba66eb61402c78
broken link from  commit c169f7c6174c6aab7e3d73b641fa1b1d8f357039
              to    tree 1da8e7214099968f5983dd3708e7f5547c54233e
broken link from  commit 1e44e4d1698738d961ab0d98d55fe071bc84aabc
              to    tree 00379fa0f87f1f43b569faa9ed27f5ee77194c9a
broken link from  commit 06269902796fbb82c0d3b137c67eaaff43d8c006
              to    tree 8171594ca9766dbc22928409d91f324bda4f5b6e
broken link from  commit c4bae07e2209fc4fb16a42506f22904e417968d5
              to    tree 0accb10ec482d8d147a219491646bdb1844f7900
broken link from  commit 1cac962da6ecacadf5dc50500cf878dfb719455c
              to    tree 92f5b9b6dce75a00f1cfcaf2a8720a008cd39dbf
broken link from  commit 2d205a9c9a5df9aa7fd68cb5da93252a32d56137
              to    tree 77ee5b3e3dbb64b0ad357e1f7f79b63947d3c463
broken link from  commit e2c9fb9442cefe8c770cfcdac4e3b952fd9f75de
              to    tree 41282dd0d7874bbd975dfba6a4b3220062baf5f2
broken link from    tree 53b7d78b72121fbb0940149b27ef362a6540a034
              to    tree 646cbf58621ff34ec936f03c576311d908b22db9
broken link from    tree 4efacb1fd154459c4611ab3770d1863e1e851a6c
              to    tree a5f1849236956ee1df7b9dfa3dce3c304de8b8ce
broken link from    tree 3c8295170af1d526ec36cd8777bcc5e6a156b172
              to    tree c24966d04e280d874b836dfefc1dbb852f00312f
broken link from  commit 512ecb68b08d3b83687f66bbd35ec6d043447894
              to    tree 1360e45db71c05957efbe0477e0e57c637f94386
broken link from  commit 1807300c82d19890eb40538566d40be224b679d8
              to    tree 312eab703a87c526cdbd13fe35d12d0b79da3f97
broken link from  commit 56c9275662753a621f34ca91f4421d7b7a12a59c
              to    tree 4e1c3f256966fbb03f92cb3063d769a2ba888aeb
broken link from  commit d491db4473c1a6fb1e06239b41058c39d51d9103
              to    tree 7bb4004476ed952fab8ee55f7812507c00be2f48
broken link from    tree f356c2002614556a9a6f2f7f97f64a09a0964d12
              to    tree 5d0ae9c466337840c95ca99b2fb5df5a20b1b676
broken link from    tree 4c5662024a6f092c39dcca7f6edc377a4756e30d
              to    tree d3c122b26b555f69d4f4967fb1e1c2b8cd4446c4
broken link from  commit 2bb804206564221dde5fddd0c344e154adb3dd63
              to    tree 95c0e173304f64ee3f820bbc134a41762184ff56
broken link from  commit 10deb742a0456449997b9f52f0b1f48ee045c37c
              to    tree 79815b8c1c01e6ea9978899dea35a5e1561b7ae4
broken link from  commit 52ac9552312504d3606083990d3cfa589bef2b01
              to    tree 89b7ce122f09a0c151414228c11efca68caa5aa0
missing tree 95c0e173304f64ee3f820bbc134a41762184ff56
dangling tree ea40c22b7c93ffa26ed1a059bc80a4bc8e8202f8
dangling tree 08c1f1e2b52b2150e8edb000c532fbde4186f25c
missing tree 79815b8c1c01e6ea9978899dea35a5e1561b7ae4
missing tree d3c122b26b555f69d4f4967fb1e1c2b8cd4446c4
missing tree 6d025930b3185c7f61dafd673bba66eb61402c78
missing tree dec220f984bd1e218180c24d301ed8d417390bd1
dangling tree a4069c00c235635faf723584341e5c8841596219
dangling tree 86c93869199fc45afe170360d8d6944b1d63a0f1
missing tree c24966d04e280d874b836dfefc1dbb852f00312f
dangling tree 518a2c61c9f97d7097575ae51d387f23ee2e5719
missing tree 5d0ae9c466337840c95ca99b2fb5df5a20b1b676
dangling tree d3ca9db98dd8423e0871decb297e01cefb76484e
dangling tree 674b6a454a10b22afc4fd7ddfc66eb92cd5cb233
missing tree 0accb10ec482d8d147a219491646bdb1844f7900
dangling tree 0213de08e741e5f053491830785599336d8c70ec
dangling tree 79d47e6c9fdb0c01136af88a0c834df945d408d1
missing tree 9d18b2f173db4b1473f454bbb1a29c4e19ba0aca
dangling tree d19a2c2b386a3ff9e22fa98c60b9b193f5a8013f
missing tree 4e1c3f256966fbb03f92cb3063d769a2ba888aeb
missing tree 1360e45db71c05957efbe0477e0e57c637f94386
dangling tree 8721feada3f3430cbdbc27afd1c9b5cb0df057a7
dangling tree 77a21101170813bf885d8e8ec5c240e18375a4f3
dangling tree 0ce6e7a3d5cefcd5a3d4bc0457ae6b99339e51de
dangling tree 5e26a4ca30838e71e278508fccbbf3f9b9ba0b69
missing tree 1da8e7214099968f5983dd3708e7f5547c54233e
missing tree 41282dd0d7874bbd975dfba6a4b3220062baf5f2
dangling tree ab6833c9b4524d7fa70dbad4991f6efd9e115b18
dangling tree 51eaf47b89abe03ff602801e19d8bd404a44469a
dangling tree 1eeb7ac6ac25796cdb284f7d336a92a2b994ce49
missing tree 646cbf58621ff34ec936f03c576311d908b22db9
missing tree 312eab703a87c526cdbd13fe35d12d0b79da3f97
missing tree 77ee5b3e3dbb64b0ad357e1f7f79b63947d3c463
dangling tree b62f1fafc96b7de40c514c76200b22b65a887208
dangling tree d97052ce3001449733a0fd0846358fdb95d84a64
missing tree 8171594ca9766dbc22928409d91f324bda4f5b6e
missing tree a5f1849236956ee1df7b9dfa3dce3c304de8b8ce
dangling tree 8573d67b631a3415e3cb6d0acaafff87fc7fdd24
missing tree 38f44bd62fac67a6932d934c68d8971ca142663e
missing tree 7bb4004476ed952fab8ee55f7812507c00be2f48
missing tree 92f5b9b6dce75a00f1cfcaf2a8720a008cd39dbf
dangling tree fc351f85b188270a3c726249e4b6608ef849877d
missing tree 00379fa0f87f1f43b569faa9ed27f5ee77194c9a
missing tree 89b7ce122f09a0c151414228c11efca68caa5aa0
missing tree 4df80ea18061bd98481a4b1d3223e4a182febd5e
dangling tree 523835b737752581d085af60818dab54048d8fe9
missing tree 2a3c114353dbbb4416a938dc8e1c371998e9e116
missing tree 80ff534035ebc424b09c7068dbe6928f4f2672cd

Sometimes the unpacker applies deltas wrong

Track down the source of the issue and fix it so that all repos can be cloned.

The js-git repo itself will reproduce this issue.

In the examples folder do:

> node clone.js git://github.com/creationix/js-git.git
...
> node walk.js conquest.git/
...
 a41b3594925a48c161ce2b5fd2fa1866dfac8a41 /

/home/tim/JSGit/js-git/examples/walk.js:22
        if (err) throw err;
                       ^
Error: ENOENT, open '/home/tim/Code/js-git/examples/js-git.git/objects/d6/f37173f8536b469112cc62f3e69bc6271ea250'

GIT server

Basic use case for MVP GIT server:

  • User wants to host files using git, controlled by nodejs.
  • There should be an event API for hooking into GIT for when a push is made to a repo for example.
  • Files need to be hosted via http, https, git, or ssh. At least one secure method is needed
  • User wants to store files in local or off-site locations (e.g. s3, mongodb, local fs...)
  • User needs the ability to clone files hosted via js-git
  • User needs the ability to push to the repo.
  • User needs the ability to host multiple repos.
  • User needs to support basic auth and ssh keys.

Want to back this issue? Place a bounty on it! We accept bounties via Bountysource.

Self Hosting

js-git should be able to in a browser:

  • clone its own source from a remote git repo
  • make new commits locally
  • fetch and merge any updates from the remote
  • push new commits to the remote

license

i know you said this would be MIT licensed and i don't doubt you... but could you add some licensing info to this repo and to the submodules?

thanks.

Add websocket protocol for web pages

Add a websocket based protocol complete with sample proxy server so that web-pages can clone while we wait on github to add CORS to http(s) repos.

Implement packed-file reading in git-fs-db.

trying out the read method, I find I can read a new object entry that exists as an unpacked object in the .git/objects directory.

but I get an ENOENT on an object hash that does not exist in the .git/objects directory if I try to read an older file that I am pretty sure is sitting in a packed object file.

just wondering if that's on the todo list - if so I'll just drop my experiments for now until it's supported - or maybe you need some help there I could try to support it?


Want to back this issue? Place a bounty on it! We accept bounties via Bountysource.

Make pre-build scripts for webpages

Maintain some pre-built scripts for easy integration with normal webpages.

  • js-git.js - Core library, sets up window.jsGit namespace. Includes websocket remote and abstract local repo. Uses memory db.
  • js-git-indexed-db.js - Plugin to replace memorydb with indexedDB storage.
  • js-git-web-fs.js - Plugin to replace memorydb with html5 filesystem storage.
  • js-git-local-storage.js - Plugin to replace memorydb with local storage.

Design fs.*, db.*, env.* and git.* public APIs

The first minimal UI for js-git will be js repl based. There are three object interfaces that need to be implemented.

db

This is a dumb key/value interface

  • db.get(key, callback) - Get a value from the database by key.
  • db.set(key, value, callback) - Write a value to the database.
  • what else do we need? Maybe delete?

db conventions for git

We'll have some conventions for mapping a git database to a generic k/v store.

  • objects are keyed by their sha1 hash (of the value itself)
  • a repository is keyed by it's random uuid (for example f47ac10b-58cc-4372-a567-0e02b2c3d479)

In the fs abstraction, .gitid files will contain the uuid of the git repo they reference.

fs

This is a generic filesystem abstraction. It represents a filesystem that may contain several git repos (though the actual git databases are stored in the db instance)

  • fs.readfile(path, callback) - the data will be null if the file doesn't exist instead of emitting an error.
  • fs.writefile(path, contents, callback) - write contents to a file, creating it if it doesn't exist.
  • fs.rmfile(path, callback) - delete a file
  • fs.readdir(path, callback) - get a listing of files in a path as an array of strings.
  • fs.mkdir(path, callback) - create a folder, creating parent directories if needed.
  • fs.rmdir(path, callback) - delete a folder and all it's contents

env

An environment is like a bash instance. It has local state. For now this means current working directory. It also can integrate with the rest of the app and do things like open files in gui programs (text editors, image viewers, html engines, etc..)

  • env.chdir(path) - change the working directory. If this env is attached to a git instance, it notifies git of the change.
  • env.cwd() - Return the current working directory
  • env.open(path, callback) - open a file for viewing in the default app (preview html)
  • env.edit(path, callback) - open a file for editing in the default app (edit html)

git env

This represents git porcelain coupled with an environment. It lets you do manage your git repos. The current working directory and current working git repo are implicit state.

  • git.init(callback) - create a new git repo in the current working directory
  • git.remotes - an object containing remote names and full urls. (TODO: how can we detect changes to this object, maybe a nextTick handler on a getter for .remotes?)
  • git.hashObject(object) - store an git object (string) in the git database by it's sha1 hash value.
  • git.updateIndex(...)
  • ... and other stuff as we implement them

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.