gitkit-js

授权协议 Apache-2.0 License
开发语言 JavaScript
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 暨弘毅
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

GitKit.js

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 Basics

State of the Git repository is represented as a single immutable Repository object. Read and write access to the repository is done using a FS driver, the implementation of the fs depends on the plaftrom (NativeFS for Node.js/Native, LocalStorageFS or MemoryFS for the browser).

var GitKit = require('gitkit');
var NativeFS = require('gitkit/lib/fs/native');

// Prepare the filesystem
var fs = NativeFS(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(newRepo) {
    // 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) { ... });
Commit changes
var author = GitKit.Person.create('Bob', 'bob@gmail.com');
var message = 'My First commit';

GitKit.CommitUtils.createForChanges(repo, author, message, changes)
    .then(function(newRepo) { ... });
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.

 相关资料
  • 问题内容: 我正在尝试使用GET方法发送一个json对象。我的代码: 但是,收到的标头将“ Content-Length”设置为零,因此服务器上的json解析器无法读取内容。 我已经尝试设置内容长度标头,但是它仍然以零的形式出现在服务器上: 任何想法如何使它工作?它必须是GET请求。 问题答案: GET请求至少通常是没有消息正文。如文档中所述,jQuery将GET请求追加到url参数。您应该能够使

  • 问题内容: 在JSF2中,是否可以使用Ajax请求动态更改ui:include的src值(例如PrimeFacesp:commandButton)?谢谢。 那就是我现在所拥有的。是否有可能使它成为Ajax(使用p:commandButton)? 问题答案: 另一个答案中提出的JSTL标签不是必需的,并且不能很好地重用。 这是一个使用纯JSF的基本示例(假设您运行Servlet 3.0 / EL 2

  • 问题内容: 我有一个基于jquery的单页webapp。它通过AJAX调用与RESTful Web服务进行通信。 我正在尝试完成以下任务: 将包含JSON数据的POST提交到REST URL。 如果请求指定JSON响应,则返回JSON。 如果请求指定PDF / XLS / etc响应,则返回可下载的二进制文件。 我现在有1&2,并且客户端jquery应用通过基于JSON数据创建DOM元素在网页上显

  • 本文向大家介绍jQuery中如何将数组转化为json字符串,然后再转化回来?相关面试题,主要包含被问及jQuery中如何将数组转化为json字符串,然后再转化回来?时的应答技巧和注意事项,需要的朋友参考一下

  • 问题内容: 我希望能够从Java操作方法中的JSON字符串访问属性。只需说一下即可使用该字符串。下面是该字符串的示例: 在此字符串中,每个JSON对象都包含其他JSON对象的数组。目的是提取ID列表,其中任何给定对象都具有包含其他JSON对象的group属性。我将Google的Gson视为潜在的JSON插件。谁能提供某种形式的指导,说明如何从此JSON字符串生成Java? 问题答案: 我将Goog

  • 问题内容: 我在文件中有此: 我编写了以下脚本来打印所有数据: 但是,该程序会引发异常: 如何解析并提取其值? 问题答案: 你的数据不是有效的格式。你有什么时候应该拥有: 用于JSON数组,在Python中称为 用于JSON对象,在Python中称为 JSON文件的外观如下: 然后,你可以使用你的代码: 有了数据,你现在还可以找到类似的值: 试试看,看看是否有意义。