If you wish to help contribute to nodegit it is useful to build locally.
# Fetch this project.git clone git://github.com/tbranyen/nodegit.git# Enter the repository.cd nodegit# Installs the template engine, run the code generation script, and build.npm install
If you encounter errors, you most likely have not configured the dependencies
correctly.
You may have to add a build flag to the installation process to successfully
install. Try first without, if the build fails, try again with the flag.
Allegedly the order in which you install Visual Studio could trigger this
error.
npm install nodegit --msvs_version=2013# Or whatever version you've installed.
API examples.
Cloning a repository and reading a file:
var clone = require("nodegit").Repository.clone;// Clone a given repository into a specific folder.clone("https://github.com/nodegit/nodegit", "tmp", null).then(function(repo) { // Use a known commit sha from this repository. var sha = "59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5"; // Look up this known commit. repo.getCommit(sha).then(function(commit) { // Look up a specific file within that commit. commit.getEntry("README.md").then(function(entry) { // Get the blob contents from the file. entry.getBlob().then(function(blob) { // Show the name, sha, and filesize in byes.
Emulating git log:
var open = require("nodegit").Repository.open;// Open the repository directory.open("tmp").then(function(repo) { // Open the master branch. repo.getMaster().then(function(branch) { // Create a new history event emitter. var history = branch.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 >=
Unit tests.
You will need to build locally before running the tests. See above.