Socket
Socket
Sign inDemoInstall

js-git

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-git - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

.jshintrc

16

BACKERS.md

@@ -1,5 +0,9 @@

# Backers
# Kickstarter Backers
Originally JS-Git started at a [kickstarter project][]. This was to enable me to spend the time required to get the project off the ground. These are the people who contributed to this fund raiser and wanted to be listed at backers.
## Deep Backer
> You really wish this project existed and probably derive some sort of commercial value out of its existence. If you're within the continental United States. I'll come to your company and spend a day helping you integrate the library into your project. Your name, url, and short blurb will be in the BACKERS.md file for all history to see.
- Mozilla <https://www.mozilla.org>

@@ -9,2 +13,4 @@

> You believe in enabling the web platform and put your money where your mouth is. To reward your generosity, I'll give personal assistance to you or your company integrating the library into your project. This can be up to an hour of video chat or several email/chat sessions. You will get a sheet of laptop stickers and your name, and optional url will be in the BACKERS.md file for all history to see.
- Michael Bradley <https://github.com/michaelsbradleyjr>

@@ -36,2 +42,4 @@ - Scott González <http://scottgonzalez.com>

> Chris decided to back with code and had been immensely helpful in getting this project started. I sent him a pack of stickers as reward.
- Chris Dickinson <https://github.com/chrisdickinson/>

@@ -41,2 +49,4 @@

> You believe this project is important and want to enable me to create it. I'll send you a vinyl laptop sticker with the awesome JSGit logo on it so you can show off your support. Your name will be in the BACKERS.md file for all history to see.
- Luke Arduini

@@ -148,2 +158,4 @@ - garza

> You really support this idea and want to do your part to help see it happen. Your name will be in the BACKERS.md file for all history to see.
- Eric Knudtson

@@ -343,1 +355,3 @@ - Damien Klinnert

- Charles Moncrief
[kickstarter project]: http://www.kickstarter.com/projects/creationix/js-git

2

examples/read-generator.js

@@ -14,3 +14,3 @@ // Bootstrap the platform to run on node.js

console.log("Looking up hash that HEAD points to...");
var hash = yield repo.getHead();
var hash = yield repo.get("HEAD");
console.log("HEAD", hash);

@@ -17,0 +17,0 @@

@@ -11,3 +11,3 @@ // Bootstrap the platform to run on node.js

console.log("Looking up hash that HEAD points to...");
repo.getHead(function (err, head) {
repo.get("HEAD", function (err, head) {
if (err) throw err;

@@ -42,2 +42,2 @@

});
}
}

@@ -9,13 +9,22 @@ var bops = require('bops');

var deflate = platform.require("deflate");
var root = platform.require("fs");
module.exports = function fsDb(path, bare) {
var fs = root(path);
var workingFs = fs;
if (!bare) fs = fs(".git");
var fs;
if (typeof path === "string") {
fs = platform.require('fs')(path);
}
else {
// Assume they passed in an fs instance.
fs = path;
}
var workingFs;
if (!bare) {
workingFs = fs;
fs = fs(".git");
}
return {
root: fs.root,
fs: workingFs,
root: fs.root,
bare: bare,
write: write,

@@ -22,0 +31,0 @@ read: read,

@@ -10,8 +10,9 @@ // Shared modules

}
platform.has = function (name) {
platform.has = has;
function has(name) {
return name in modules;
};
platform.require = function (name) {
if (!(name in modules)) throw new Error("Platform does not implement " + name + " interface");
if (!has(name)) throw new Error("Platform does not implement " + name + " interface");
return modules[name];
};

@@ -68,3 +68,3 @@ var each = require('../helpers/each.js');

root: db.root,
bare: db.bare,
bare: !db.fs,
init: db.init,

@@ -214,4 +214,4 @@ saveBlob: saveBlob,

if (err) return callback(err);
version = stats.version,
num = stats.num,
version = stats.version;
num = stats.num;
packStream.read(onRead);

@@ -305,3 +305,3 @@ });

remove();
})
});
}

@@ -312,2 +312,3 @@ }

function get(ref, callback) {
if (!callback) return get.bind(this, ref);
if (/^[0-9a-fA-F]{40}$/.test(ref)) return callback(null, ref);

@@ -435,7 +436,7 @@ db.read(ref, function (err, value) {

}
};
}
function checkout(ref, callback) {
if (!callback) return checkout.bind(this, ref);
if (db.bare) return callback(new Error("Cannot checkout in a bare repo"));
if (!db.fs) return callback(new Error("Cannot checkout in a bare repo"));
var fs = db.fs;

@@ -442,0 +443,0 @@ var files = [];

{
"name": "js-git",
"version": "0.2.3",
"version": "0.2.4",
"description": "Git Implemented in JavaScript",

@@ -18,2 +18,5 @@ "repository": {

},
"scripts": {
"test": "find . -name '*.js' | grep -v node_modules | grep -v min.js | xargs jshint"
},
"dependencies": {

@@ -26,4 +29,5 @@ "bops": "~0.0.6",

"js-git-node-platform": "~0.2.0",
"gen-run": "~0.1.0"
"gen-run": "~0.1.0",
"jshint": "~2.1.9"
}
}

@@ -27,3 +27,3 @@ var platform = require('../lib/platform.js');

fetch: fetch,
close: close
close: closeConnection
};

@@ -232,4 +232,4 @@

function close(callback) {
if (!callback) return close.bind(this);
function closeConnection(callback) {
if (!callback) return closeConnection.bind(this);
callback();

@@ -236,0 +236,0 @@ }

@@ -26,3 +26,3 @@ var platform = require('../lib/platform.js');

fetch: fetch,
close: close
close: closeConnection
};

@@ -62,6 +62,8 @@

if (!callback) return discover.bind(this);
if (!connection) return connect("git-upload-pack", function (err) {
if (err) return callback(err);
return discover(callback);
});
if (!connection) {
return connect("git-upload-pack", function (err) {
if (err) return callback(err);
return discover(callback);
});
}
sharedDiscover(connection, callback);

@@ -80,4 +82,4 @@ }

function close(callback) {
if (!callback) return close.bind(this);
function closeConnection(callback) {
if (!callback) return closeConnection.bind(this);
connection.write();

@@ -84,0 +86,0 @@ tunnel.close(function (err) {

@@ -24,3 +24,3 @@ var platform = require('../lib/platform.js');

fetch: fetch,
close: close,
close: closeConnection,
};

@@ -55,6 +55,8 @@

if (!callback) return discover.bind(this);
if (!connection) return connect(function (err) {
if (err) return callback(err);
return discover(callback);
});
if (!connection) {
return connect(function (err) {
if (err) return callback(err);
return discover(callback);
});
}
connection.write("git-upload-pack " + opts.pathname + "\0host=" + opts.hostname + "\0");

@@ -74,4 +76,4 @@ sharedDiscover(connection, callback);

function close(callback) {
if (!callback) return close.bind(this);
function closeConnection(callback) {
if (!callback) return closeConnection.bind(this);
connection.write(null);

@@ -78,0 +80,0 @@ callback();

@@ -25,3 +25,3 @@ # JS-Git

I don't intent to make a 100% clone of all the features of the official git program. That would be insane and require a lot more money than I'm asking for. My main goal is to enable the 90% case of interesting stuff:
I don't intend to make a 100% clone of all the features of the official git program. That would be insane and require a lot more money than I'm asking for. My main goal is to enable the 90% case of interesting stuff:

@@ -50,3 +50,3 @@ - Clone remote repositories to local storage over http, git, or ssh.

My main driving force is to build a programming environment to teach kids to program. It needs to run on the devices that the kids already have. There are a lot of youth who have access to tablets or Chromebooks, but have no way to program properly on them. I want to change this and give them the tools to eventually become professional programmers.
My main driving force is to build a programming environment to teach kids to program. It needs to run on the devices that the kids already have. There are many youths who have access to tablets or Chromebooks, but have no way to program properly on them. I want to change this and give them the tools to eventually become professional programmers.

@@ -59,3 +59,3 @@ #### JS-Git in a Chrome App

This app is still in the early stages, It's available in the Chrome [app store][] to test on any device that has Chrome installed.
This app is still in the early stages. It's available in the Chrome [app store][] to test on any device that has Chrome installed.

@@ -70,17 +70,3 @@ #### JS-Git as a Node.JS CLI Tool

## Related Packages
Not all parts of js-git are in this package. Of note, the min-stream code is already factored out into several standalone packages.
- [min-stream][] - Helpers for working with min-streams.
- [min-stream-node][] - A node.js adapter that provides tcp client and server as well as file streams using min-streams.
- [min-stream-uv][] - A crazy experiment to implement the same interface as min-stream-node, but using node's private internal libuv bindings for maximum speed and unstability.
- [min-stream-chrome][] - Another implementation of the tcp and fs API, but wrapping chrome packaged apps's special APIs.
- [min-stream-http-codec][] - A set of filters that makes implementing HTTP clients and servers easy.
## Projects using JS-Git
- [js-git-app][] - A chrome packaged app used to demo/test using js-git in a chrome environment.
- [js-git-node][] - A node CLI tool used to demo/test using js-git in the node.js environment.
[node.js]: http://nodejs.org

@@ -90,9 +76,4 @@ [git]: http://git-scm.com/

[chrome packaged apps]: http://developer.chrome.com/apps/
[min-stream]: https://github.com/creationix/min-stream
[min-stream-node]: https://github.com/creationix/min-stream-node
[min-stream-uv]: https://github.com/creationix/min-stream-uv
[min-stream-chrome]: https://github.com/creationix/min-stream-chrome
[min-stream-http-codec]: https://github.com/creationix/min-stream-http-codec
[js-git-app]: https://github.com/creationix/js-git-app
[js-git-node]: https://github.com/creationix/js-git-node
[app store]: https://chrome.google.com/webstore/detail/js-git-test-app/gcipadbniegpaccphmnfnpgklahgennp

@@ -26,3 +26,3 @@ # File System

- ino
- mode 1000,1010,1110 | 0755,0644
- mode (executable file 0100755, normal file 0100644, symlink 0120000)
- uid

@@ -36,34 +36,10 @@ - gid

## read(path, [encoding]) -> continuable<binary_or_string>
## read(path, encoding) -> continuable<binary_or_string>
Read a file as a single string or binary buffer
## write(path, value, [encoding]) -> continuable
## write(path, value, mode) -> continuable
Write a file as a single string or binary buffer
## readStream(path, [options]) -> continuable&lt;stream>
Open a file by path for reading and return a simple-stream.
- options.start - start at offset
- options.end - end at offset
```js
var input = yield fs.readStream("/path/to/my/file.txt");
```
## writeStream(path, [options]) -> continuable&lt;sink>
Create a simple-stream sink that saves the stream to disk.
- options.mode - create file with custom mode (base 8 string or integer)
```js
var save = yield fs.writeStream("/path/to/output.txt");
console.log("Saving input to disk...");
yield save(input);
console.log("Saved");
```
## unlink(path) -> continuable

@@ -93,8 +69,8 @@

## readdir(path) -> continuable&lt;stream>
## readdir(path) -> continuable&lt;files>
Returns a stream of filenames in the target path.
Returns an array of filenames in the target path.
```js
var nameStream = yield fs.readdir("..");
var files = yield fs.readdir("..");
```

@@ -149,3 +125,3 @@

- [simple-fs](https://github.com/creationix/simple-fs) - Implementation for Node.JS
- [js-git-node-platform](https://github.com/creationix/js-git-node-platform) - Implementation for Node.JS

@@ -152,0 +128,0 @@ [gen-run]: https://github.com/creationix/gen-run

@@ -1,4 +0,1 @@

*WARNING* This spec is out of date, update coming shortly. See <https://github.com/creationix/git-fs-db> for now.
# Git Database

@@ -10,3 +7,3 @@

All examples use `yield` to consume [continuables][], assuming generators with [gen-run][] wrapping, but can be used with ES5 code as well. Streams are in [min-stream][] format.
All examples use `yield` to consume [continuables][], assuming generators with [gen-run][] wrapping, but can be used with ES5 code as well. Streams are in [simple-stream][] format.

@@ -24,6 +21,10 @@ ```js

## load(hash) -> source&lt;binary>
## fs (working directory)
Given an object hash, return a data stream.
If the db also has a working directory (a non-bare repo), then fs is the [fs interface][] instance to the working directory.
## load(hash) -> continuable&lt;object>
Given an object hash, return a raw object.
```js

@@ -33,45 +34,39 @@ var stream = db.load(hash);

## save(source) -> continuable&lt;hash>
Raw objects have the following structure:
Save an object to the database. Source is a binary data stream already git encoded.
The output is the SHA1 hash (hex encoded) of the stream's contents where the data can later be retrieved.
```js
var hash = yield db.save(stream);
{
type: ("tree" | "blob" | "commit" | or "tag")
body: Buffer
}
```
## read(path) -> continuable&lt;hash>
## save(object) -> continuable&lt;hash>
Read a ref by path. This will auto-resolve symbolic refs.
Save a raw object to the database. Note that the body needs to be already encoded, but not include the type and length headers.
```js
var hash = yield db.read("HEAD");
```
The output is the SHA1 hash (hex encoded) of the data (header included) where the data can later be retrieved.
## write(path, hash) -> continuable
Write a ref to the database.
```js
yield db.write("/refs/heads/master", hash);
var hash = yield db.save(stream);
```
## listObjects() -> source&lt;hash>
## read(path) -> continuable&lt;string>
Create a stream of all the hash keys in the database.
Read a ref by path. This does not auto-resolve symbolic refs.
```js
var hashStream = db.listObjects();
var sym = yield db.read("HEAD");
```
## listRefs() -> source&lt;path>
## write(path, string) -> continuable
Create a stream that emits all ref paths.
Write a ref to the database.
```js
var pathStream = db.listRefs();
yield db.write("/refs/heads/master", hash);
yield db.write("HEAD", "ref: /refs/heads/master");
```
## removeObject(hash) -> continuable
## remove(hash) -> continuable

@@ -81,22 +76,12 @@ Given a hash, remove an object from the database.

```js
yield db.removeObject(hash);
yield db.remove(hash);
```
## removeRef(path) -> continuable
Delete a ref by path.
```js
yield db.removeRef("/refs/heads/temp");
```
# Concrete Implementations
There isn't one yet, but a generic one that builds on top of a generic K/V store and the [sha1][] interface could easly be build as long as the K/V store allowed for renames or naming after writing.
JS-Git comes with an adapter that implements this interface on top of a [fs interface] instance at `require('js-git/lib/fs-db.js')`.
- [git-repo/fs-db.js](https://github.com/creationix/git-repo/blob/master/fs-db.js) An in-progress implementation that sits on top of a fs interface isntance.
[gen-run]: https://github.com/creationix/gen-run
[continuables]: https://github.com/creationix/js-git/blob/master/specs/continuable.md
[sha1]: https://github.com/creationix/js-git/blob/master/specs/sha1.md
[min-stream]: https://github.com/creationix/js-git/blob/master/specs/min-stream.md
[simple-stream]: https://github.com/creationix/js-git/blob/master/specs/simple-stream.md
[fs interface]: https://github.com/creationix/js-git/blob/master/specs/fs.md
# TCP
This interface describes the TCP client and server interface used in the js-git project.
This interface describes the TCP client interface used in the js-git project.
Streams are in [min-stream][] format.
Streams are in [simple-stream][] format.
## createServer(port, [host]) -> stream&lt;socket>
Create a TCP server listening on `port` and `host` (defaulting to localhost). The stream is a connection stream. It emits an event every time a new client connects.
The connection events in the stream are objects that contain a socket source and sink representing the duplex TCP socket.
```js
var server = tcp.createServer(8080);
// Get the first client and make them talk to themselves.
server(null, function (err, client) {
if (err) throw err;
client.sink(client.source);
// Then close the server to disallow more connections
server(true, function (err) {
if (err) throw err;
console.log("Server closed");
});
});
```
## connect(port, [host]) -> continuable&lt;socket>

@@ -32,9 +11,9 @@

Returns a continuable for a socket object containing source and sink min-streams representing the duplex socket.
Returns a continuable for a socket object containing a duplex simple-stream `{read, abort, sink}` representing the socket.
```js
tcp.connect(8080)(function (err, socket) {
tcp.connect(8080, function (err, socket) {
if (err) throw err;
// Make the server talk to itself
socket.sink(socket.source)(function (err) {
socket.sink(socket)(function (err) {
if (err) throw err;

@@ -50,3 +29,3 @@ console.log("Connection ended");

var socket = yield tcp.connect(8080);
yield socket.sink(socket.source);
yield socket.sink(socket);
```

@@ -56,6 +35,6 @@

- [min-tcp](https://github.com/creationix/min-tcp) - Implementation for Node.JS
- [js-git-node-platform](https://github.com/creationix/js-git-node-platform) - Implementation for Node.JS
[min-stream]: https://github.com/creationix/js-git/blob/master/specs/min-stream.md
[simple-stream]: https://github.com/creationix/js-git/blob/master/specs/simple-stream.md
[gen-run]: https://github.com/creationix/gen-run
[continuables]: https://github.com/creationix/js-git/blob/master/specs/continuable.md

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc