gitkit

0.1.0 • Public • Published

GitKit.js

NPM version Linux Build Status Windows Build status

Pure JavaScript implementation of Git backed by immutable models and promises.

The goal is to provide both a low and high level API for manipulating Git repositories: read files, commit changes, edit working index, clone, push, fetch, etc.

This library can work both in the browser and Node.js.

Installation

$ npm install gitkit

Usage

API

var GitKit = require('gitkit');
var NodeFS = require('gitkit/lib/fs/node');
 
// Prepare the filesystem
var fs = NodeFS(process.cwd());
 
// Create a repository instance
var repo = GitKit.Repository.createWithFS(fs, isBare);
Clone a remote repository
// Create a transport instance for the GitHub repository
var transport = new GitKit.HTTPTransport('https://github.com/GitbookIO/gitbook.git');
 
GitKit.TransferUtils.clone(repo, transport)
.then(function() {
    // Clone succeed!
}, function(err) {
    // Clone failed
})
List branches

GitKit.BranchUtils.list returns a promise listing branches as a list of strings.

GitKit.BranchUtils.list(repo)
    .then(function(branches) { ... })
Get current branch

GitKit.BranchUtils.getCurrent returns a promise resolved with the name of the current active branch.

GitKit.BranchUtils.getCurrent(repo)
    .then(function(branch) { ... })
List files in repository

GitKit.WorkingIndex provides a set of methods to work with the working index.

GitKit.WorkingIndex.readFromRepo(repo)
    .then(function(workingIndex) {
        var entries = workingIndex.getEntries();
    });
List changes not staged for commit

GitKit.ChangesUtils provides a set of methods to work with pending changes.

GitKit.ChangesUtils.list(repo)
    .then(function(changes) { ... });
More example and documentation coming soon!

I'll publish a better documentation for this library soon.

Thanks

To the people pointing me in the right directions like:

License

GitKit.js is Apache-licensed.

Readme

Keywords

none

Package Sidebar

Install

npm i gitkit

Weekly Downloads

0

Version

0.1.0

License

Apache-2.0

Last publish

Collaborators

  • samypesse