节点吉特
节点约束 缩写2 项目.
稳定[email protected] (英语):0.28.3 (中文(简体) )
有问题吗? 跟我们聊聊吧!
访问 libgit2.org (英语) 加入我们.
维护者
泰勒·昂-瓦内克 @twwanek (英语) 以吨计的帮助 伟大的贡献者来啊!
校友维护者
蒂姆·布兰延 @tbranyen (英语), (中文(简体) ), 约翰·海利 @johnhaley81 (英语), (中文(简体) ), 马克斯·克普 @maxkorp (英语), (中文(简体) ), 史蒂夫・史密斯 @ 顺序列表, (中文(简体) ), 迈克尔·鲁滨逊 @ codeof 兴趣,以及 尼克·卡伦 时间轴:
API文档.
http://www.nodegit.org/ (中文(简体) )
开始吧.
节点Git 将工作在大多数系统外 没有本地 依赖性.
npm install nodegit
如果您收到libstdc++的错误, 通常在 在Travis-CI上,你可以通过升级到最新的 libstdc++-4.9. (英语).
在乌本图:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install libstdc++-4.9-dev
在特拉维斯:
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libstdc++-4.9-dev
在圆CI中:
dependencies:
pre:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update
- sudo apt-get install -y libstdc++-4.9-dev
如果您收到错误 生命周期脚本 安装前/安装时可能错过 libssl- dev (英语) 在乌本图:
sudo apt-get install libssl-dev
您需要安装在您的 linux 机上的以下库 :
- 节点
- libpcreposix 语言
- 第5节
- libk5crypto 语录
- libcom err (英语)
在本地建设时, 您还需要 Kerberos 和 pcre 的开发软件包, 所以这两个公用设施都必须出现在您的机器上 :
- pcre- 配置
- krb5 配置
如果安装时仍然遇到问题,请尝试 从源头建楼 说明.
API的例子.
复制寄存器并读取文件 :
var Git = require("nodegit");
// Clone a given repository into the `./tmp` folder.
Git.Clone("https://github.com/nodegit/nodegit", "./tmp")
// Look up this known commit.
.then(function(repo) {
// Use a known commit sha from this repository.
return repo.getCommit("59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5");
})
// Look up a specific file within that commit.
.then(function(commit) {
return commit.getEntry("README.md");
})
// Get the blob contents from the file.
.then(function(entry) {
// Patch the blob to contain a reference to the entry.
return entry.getBlob().then(function(blob) {
blob.entry = entry;
return blob;
});
})
// Display information about the blob.
.then(function(blob) {
// Show the path, sha, and filesize in bytes.
console.log(blob.entry.path() + blob.entry.sha() + blob.rawsize() + "b");
// Show a spacer.
console.log(Array(72).join("=") + "\n\n");
// Show the entire file.
console.log(String(blob));
})
.catch(function(err) { console.log(err); });
模拟 git 日志 :
var Git = require("nodegit");
// Open the repository directory.
Git.Repository.open("tmp")
// Open the master branch.
.then(function(repo) {
return repo.getMasterCommit();
})
// Display information about commits on master.
.then(function(firstCommitOnMaster) {
// Create a new history event emitter.
var history = firstCommitOnMaster.history();
// Create a counter to only show up to 9 entries.
var count = 0;
// Listen for commit events from the history.
history.on("commit", function(commit) {
// Disregard commits past 9.
if (++count >= 9) {
return;
}
// Show the commit sha.
console.log("commit " + commit.sha());
// Store the author object.
var author = commit.author();
// Display author information.
console.log("Author:\t" + author.name() + " <" + author.email() + ">");
// Show the commit date.
console.log("Date:\t" + commit.date());
// Give some space and show the message.
console.log("\n " + commit.message());
});
// Start emitting events.
history.start();
});
更多实例请检查 examples/ 文件夹.
单位测试.
在进行测试之前,您需要在当地建设。 见上.
npm test