nodegit
Node.js libgit2 asynchronous native bindings
Last updated a month ago by implausibility .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install nodegit 
SYNC missed versions from official npm registry.

NodeGit

Node bindings to the libgit2 project.

Actions Status

Stable (libgit2@v0.28.3): 0.28.3

Have a problem? Come chat with us!

Visit slack.libgit2.org to sign up, then join us in #nodegit.

Maintained by

Tyler Ang-Wanek @twwanek with help from tons of awesome contributors!

Alumni Maintainers

Tim Branyen @tbranyen, John Haley @johnhaley81, Max Korp @maxkorp, 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 receive errors about lifecycleScripts preinstall/install you probably miss libssl-dev In Ubuntu:

sudo apt-get install libssl-dev

You will need the following libraries installed on your linux machine:

  • libpcre
  • libpcreposix
  • libkrb5
  • libk5crypto
  • libcom_err

When building locally, you will also need development packages for kerberos and pcre, so both of these utilities must be present on your machine:

  • pcre-config
  • krb5-config

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");

// 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); });

Emulating git log:

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();
  });

For more examples, check the examples/ folder.

Unit tests.

You will need to build locally before running the tests. See above.

npm test

Current Tags

  • 0.26.5                                ...           latest (a month ago)
  • 0.0.103                                ...           libssh2test (4 years ago)
  • 0.27.0-alpha.1                                ...           next (9 days ago)
  • 0.0.10000005                                ...           npmrc (4 years ago)

122 Versions

  • 0.27.0-alpha.1                                ...           9 days ago
  • 0.26.5                                ...           a month ago
  • 0.26.4                                ...           3 months ago
  • 0.26.3                                ...           4 months ago
  • 0.26.2                                ...           6 months ago
  • 0.26.1                                ...           7 months ago
  • 0.26.0                                ...           7 months ago
  • 0.25.1                                ...           8 months ago
  • 0.25.0                                ...           8 months ago
  • 0.25.0-alpha.16                                ...           8 months ago
  • 0.25.0-alpha.15                                ...           9 months ago
  • 0.25.0-alpha.14                                ...           9 months ago
  • 0.25.0-alpha.13                                ...           9 months ago
  • 0.25.0-alpha.12                                ...           10 months ago
  • 0.25.0-alpha.11                                ...           a year ago
  • 0.24.3                                ...           a year ago
  • 0.25.0-alpha.10                                ...           a year ago
  • 0.24.2                                ...           a year ago
  • 0.25.0-alpha.9                                ...           a year ago
  • 0.25.0-alpha.8                                ...           a year ago
  • 0.25.0-alpha.7                                ...           a year ago
  • 0.25.0-alpha.6                                ...           a year ago
  • 0.24.1                                ...           a year ago
  • 0.23.1                                ...           a year ago
  • 0.25.0-alpha.5                                ...           a year ago
  • 0.25.0-alpha.4                                ...           a year ago
  • 0.25.0-alpha.3                                ...           a year ago
  • 0.25.0-alpha.2                                ...           a year ago
  • 0.25.0-alpha.1                                ...           a year ago
  • 0.24.0                                ...           a year ago
  • 0.24.0-alpha.1                                ...           a year ago
  • 0.23.0                                ...           a year ago
  • 0.23.0-alpha.2                                ...           a year ago
  • 0.23.0-alpha.1                                ...           2 years ago
  • 0.22.2                                ...           2 years ago
  • 0.22.1                                ...           2 years ago
  • 0.22.0                                ...           2 years ago
  • 0.21.2                                ...           2 years ago
  • 0.21.1                                ...           2 years ago
  • 0.21.0                                ...           2 years ago
  • 0.20.3                                ...           2 years ago
  • 0.20.2                                ...           3 years ago
  • 0.20.1                                ...           3 years ago
  • 0.20.0                                ...           3 years ago
  • 0.18.3                                ...           3 years ago
  • 0.18.2                                ...           3 years ago
  • 0.18.1                                ...           3 years ago
  • 0.19.0                                ...           3 years ago
  • 0.18.0                                ...           3 years ago
  • 0.17.0                                ...           3 years ago
  • 0.16.0                                ...           4 years ago
  • 0.14.1                                ...           4 years ago
  • 0.15.1                                ...           4 years ago
  • 0.15.0                                ...           4 years ago
  • 0.14.0                                ...           4 years ago
  • 0.13.2                                ...           4 years ago
  • 0.13.1                                ...           4 years ago
  • 0.13.0                                ...           4 years ago
  • 0.12.2                                ...           4 years ago
  • 0.12.1                                ...           4 years ago
  • 0.12.0                                ...           4 years ago
  • 0.11.9                                ...           4 years ago
  • 0.11.8                                ...           4 years ago
  • 0.11.7                                ...           4 years ago
  • 0.11.6                                ...           4 years ago
  • 0.11.5                                ...           4 years ago
  • 0.11.4                                ...           4 years ago
  • 0.11.3                                ...           4 years ago
  • 0.11.2                                ...           4 years ago
  • 0.11.1                                ...           4 years ago
  • 0.11.0                                ...           4 years ago
  • 0.10.0                                ...           4 years ago
  • 0.9.0                                ...           4 years ago
  • 0.8.0                                ...           4 years ago
  • 0.7.0                                ...           4 years ago
  • 0.6.3                                ...           4 years ago
  • 0.6.2                                ...           4 years ago
  • 0.0.103                                ...           4 years ago
  • 0.0.102                                ...           4 years ago
  • 0.0.101                                ...           4 years ago
  • 0.6.1                                ...           4 years ago
  • 0.6.0                                ...           4 years ago
  • 0.0.10000005                                ...           4 years ago
  • 0.0.10000004                                ...           4 years ago
  • 0.0.10000003                                ...           4 years ago
  • 0.0.10000002                                ...           4 years ago
  • 0.0.10000001                                ...           4 years ago
  • 0.5.0                                ...           5 years ago
  • 0.4.1                                ...           5 years ago
  • 0.4.0                                ...           5 years ago
  • 0.3.3                                ...           5 years ago
  • 0.3.2                                ...           5 years ago
  • 0.3.1                                ...           5 years ago
  • 0.2.7                                ...           5 years ago
  • 0.2.6                                ...           5 years ago
  • 0.2.5 [deprecated]           ...           5 years ago
  • 0.2.4                                ...           5 years ago
  • 0.2.3                                ...           5 years ago
  • 0.2.2                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.4                                ...           6 years ago
  • 0.1.3                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           7 years ago
  • 0.0.79                                ...           7 years ago
  • 0.0.78                                ...           7 years ago
  • 0.0.77                                ...           7 years ago
  • 0.0.76                                ...           7 years ago
  • 0.0.75                                ...           7 years ago
  • 0.0.74                                ...           7 years ago
  • 0.0.73                                ...           7 years ago
  • 0.0.72                                ...           7 years ago
  • 0.0.71                                ...           7 years ago
  • 0.0.7                                ...           7 years ago
  • 0.0.6                                ...           8 years ago
  • 0.0.5                                ...           9 years ago
  • 0.0.4                                ...           9 years ago
  • 0.0.3                                ...           9 years ago
  • 0.0.2                                ...           9 years ago
  • 0.0.1                                ...           9 years ago
Downloads
Today 1
This Week 77
This Month 53
Last Day 1
Last Week 164
Last Month 923
Dependencies (10)
Dev Dependencies (13)
Dependents (846)

Copyright 2014 - 2017 © taobao.org |