NodeGit
Node bindings to the libgit2 project.
Linux | OS X | Windows | Coverage | Dependencies |
---|
|
|
|
|
Stable (libgit2#master): 0.17.0
Stable (libgit2@0.24): 0.14.1
Have a problem? Come chat with us!
Visit slack.libgit2.org to sign up, then join us in #nodegit.
Maintained by
Tim Branyen @tbranyen,
John Haley @johnhaley81, and
Max Korp @maxkorp with help from tons of
awesome contributors!
Alumni Maintainers
Steve Smith @orderedlist,
Michael Robinson @codeofinterest, and
Nick Kallen @nk
API Documentation.
http://www.nodegit.org/
Getting started.
NodeGit will work on most systems out-of-the-box without any native
dependencies.
npm install nodegit
If you receive errors about libstdc++, which are commonly experienced when
building on Travis-CI, you can fix this by upgrading to the latest
libstdc++-4.9.
In Ubuntu:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install libstdc++-4.9-dev
In Travis:
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libstdc++-4.9-dev
In CircleCI:
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
If you are still encountering problems while installing, you should try the
Building from source
instructions.
API examples.
Cloning a repository and reading a file:
var Git = require("nodegit");
Git.Clone("https://github.com/nodegit/nodegit", "./tmp")
.then(function(repo) {
return repo.getCommit("59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5");
})
.then(function(commit) {
return commit.getEntry("README.md");
})
.then(function(entry) {
return entry.getBlob().then(function(blob) {
blob.entry = entry;
return blob;
});
})
.then(function(blob) {
console.log(blob.entry.path() + blob.entry.sha() + blob.rawsize() + "b");
console.log(Array(72).join("=") + "\n\n");
console.log(String(blob));
})
.catch(function(err) { console.log(err); });
Emulating git log:
var Git = require("nodegit");
Git.Repository.open("tmp")
.then(function(repo) {
return repo.getMasterCommit();
})
.then(function(firstCommitOnMaster) {
var history = firstCommitOnMaster.history();
var count = 0;
history.on("commit", function(commit) {
if (++count >= 9) {
return;
}
console.log("commit " + commit.sha());
var author = commit.author();
console.log("Author:\t" + author.name() + " <" + author.email() + ">");
console.log("Date:\t" + commit.date());
console.log("\n " + commit.message());
});
history.start();
});
For more examples, check the examples/
folder.
Unit tests.
You will need to build locally before running the tests. See above.
npm test
<a name="v0-17-0" href="#v0-17-0">v0.17.0</a> (2017-01-06)
Full Changelog
Targeted Platform Changes
In this release we had added support for Node v7 and latest Electron. We have removed support for Node v0.12 and v5.
We are also deprecating nw.js support since it is currently broken, no one in the current team uses it and we would not be able to currently support nw.js in an effective manner with a good user experience.
Now building against shared libcurl lib
For proxy support we now use libcurl for HTTP/HTTPS transport which should have no noticeable change in NodeGit remote operations but if changes are noticed this is worth mentioning as a potential source.
Memory leak fixes and stability increases
Many PR's were made to fix memory leaks as they were found so memory usage should go down in this version for long running scripts. Additionally, when performing operations with callbacks (transfer progress, credentials, etc...) there was a small chance for a segfault when NodeGit would schedule the callback to go into JavaScript. This is now fixed.
Fixes to the build
Many users, especially on windows, were experiencing errors during the build. The build still isn't perfect but a lot of the bugs were fixed.
Bump libgit2 to 0bf0526
The majority of changes to NodeGit v17 were in libgit2. The API breaking changes that are known are:
Summary of changes that were brought in:
https://github.com/nodegit/nodegit/pull/1187#issuecomment-277760323
Changes to NodeGit outside of libgit2 bump
- Define GIT_SSH_MEMORY_CREDENTIALS for libgit2 PR #949
- Add "Path" to ssh variable names in tests for clarity PR #1135
- Fix revwalk memory leaks PR #1137
- Fix tree entry leaks PR #1138
- Fix typo in postinstall script PR #1141
- Fix windows exception handling in build PR #1143
- Fix CI failures on node 0.12 PR #1144
- Fix postinstall script crash when install location has spaces in its path PR #1148
- Update 0.13 changelog PR #1151
- Minor documentation fix in Checkout.index PR #1164
- FreeBSD also uses struct timespec st_mtim PR #1165
- README.md needs to show where to get Slack invitation PR #1170
- Add @async tag to
Tree#getEntry
PR #1178 - Fix incorrect anchor link in TESTING.md PR #1179
- Added tests for Tag PR #1180
- Added tests for Branch PR #1181
- Escape the spaces in dir for shell command PR #1186
- Bump libgit to 0bf0526 PR #1187
- Checkout's tree* functions do not support Oid as a parameter PR #1190
- Build against shared library for libcurl PR #1195
- Move libuv calls to correct thread PR #1197
- Update
Repository#createBranch
docs PR #1198 - Remove Node v0.12 and v5 PR #1199
- Specify acceptable types for
lookup
and dwim
in Reference PR #1203 - Build for Node 7.4.0 PR #1204
- Write the index to a repository directly in merge-cleanly.js examples PR #1205