Security News
npm Updates Search Experience with New Objective Sorting Options
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Node bindings to the libgit2 project.
Linux | OS X | Windows | Coverage | Dependencies |
---|---|---|---|---|
Stable: 0.4.1
Tim Branyen @tbranyen, John Haley @johnhaley81, Max Korp @maxkorp, and Steve Smith @orderedlist with help from tons of awesome contributors!
Michael Robinson @codeofinterest, and Nick Kallen @nk
NodeGit will work on most systems out-of-the-box without any native dependencies.
npm install nodegit
Note: NodeGit will only work on io.js Windows with the iojs binary instead of node.
If you encounter problems while installing, you should try the Building from source instructions below.
var clone = require("./").Clone.clone;
// Clone a given repository into a specific folder.
clone("https://github.com/nodegit/nodegit", "tmp", null)
// 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 name, sha, and filesize in bytes.
console.log(blob.entry.name() + blob.entry.sha() + blob.size() + "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); });
var open = require("nodegit").Repository.open;
// Open the repository directory.
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();
});
For more examples, check the examples/
folder.
You will need to build locally before running the tests. See above.
npm test
The bump from 0.1.4 to 0.2.0 was a big one. Many things changed, see here: https://github.com/nodegit/nodegit/compare/v0.1.4...v0.2.0
This update is wholly and entirely a breaking one, and older versions won't be maintained. For the purpose of migration, perhaps the biggest point to make is that async methods can now use promises, rather than just taking callbacks. Additionally, lots of method and property names have changed.
A common issue is with NodeGit not functioning properly inside of
nw.js applications. Because NodeGit
is a native module, it has to be rebuilt for node-webkit using
nw-gyp. By default, NodeGit will look
in the root package's package.json for an engines
property, and within look
for a nw.js
property (or a node-webkit
if the prior isn't found) that holds
a specific version of nw.js. The value of this property is what will get passed
as the --target
argument to nw-gyp configure
.
Prior to version 0.2.6, NodeGit used nan v1.4.3. As of 0.2.6, NodeGit uses nan v1.5.1 to provide support for io.js. Unfortunately, this breaks some nw.js compatibility. With nw.js 0.12+, the name was changed to nw.js from node-webkit. The alpha currently still breaks with NodeGit due to the nan update, but should be fixed in the final v0.12.0 release. Åpplications using previous versions of node webkit have 2 options:
Currently, support for nw.js is limited, although we intend to support it better in the future.
<a name="v0-4-1" href="#v0-4-1">v0.4.1</a> (2015-06-02)
Closed issues:
Error: Module did not self-register #593
A guide on how to create a new branch, switch to it and delete it. #588
A way to get "gone" branches #583
Missing documentation pages for BranchIterator and NodeIterator #581
ELIFECYCLE error on npm rebuild
#578
npm rebuild fails (lifecycleScripts/clean should not delete lifecycleScripts!) #576
Unable to compile and install v0.4.0 on Windows #575
Doesn't work with Electron #574
Doesn't work with io.js 2.x #573
Getting an exception during a fetchAll in defaultSignature in repository.js #572
tree_entry path function not working when calling getEntry with a path including subdir #570
Build is broken on windows #565
Cloning git sub modules using "nodegit" npm module #560
How to get remote latest commit? #559
npm install fails for nw.js #558
nodegit and nw.js #557
Merged pull requests:
Fix for issue #591. TreeEntry.path() throws when TreeEntry came from Tree.entries() #592 (tomruggs)
Add git\_index\_conflict\_get
and test #586 (johnhaley81)
Bump nan #584 (johnhaley81)
Fix CI false positives #582 (johnhaley81)
Check for existence to avoid throwing an error when there is no default signature #577 (tomruggs)
Fix path function in tree_entry (fix for issue #570) #571 (jfremy)
FAQs
Node.js libgit2 asynchronous native bindings
The npm package nodegit receives a total of 36,749 weekly downloads. As such, nodegit popularity was classified as popular.
We found that nodegit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.