MCPcopy Index your code
hub / github.com/nodegit/nodegit

github.com/nodegit/nodegit @v0.27.0 sqlite

repository ↗ · DeepWiki ↗ · release v0.27.0 ↗
102 symbols 215 edges 176 files 4 documented · 4% 2 cross-repo links
README

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

Core symbols most depended-on inside this repo

normalizeOptions
called by 54
lib/utils/normalize_options.js
garbageCollect
called by 22
test/utils/garbage_collect.js
removeFileFromIndex
called by 21
test/tests/rebase.js
commitFile
called by 16
test/tests/blob.js
reinitialize
called by 13
test/tests/commit.js
testStatusFile
called by 13
test/tests/status_file.js
shallowClone
called by 12
lib/utils/shallow_clone.js
compareFilemodes
called by 10
test/tests/stage.js

Shape

Function 102

Languages

TypeScript100%

Modules by API surface

lib/repository.js13 symbols
utils/acquireOpenSSL.js9 symbols
utils/discoverOpenSSLDistros.js7 symbols
test/tests/stage.js4 symbols
test/tests/commit.js4 symbols
utils/retry.js3 symbols
test/tests/stash.js3 symbols
test/tests/revwalk.js3 symbols
lib/revwalk.js3 symbols
test/tests/tag.js2 symbols
test/tests/repository.js2 symbols
lib/status_file.js2 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

aws-sdk2.326.0 · 1×
babel-cli6.7.7 · 1×
babel-preset-es20156.6.0 · 1×
cheerio1.0.0-rc.2 · 1×
clean-for-publish1.0.2 · 1×
combyne0.8.1 · 1×
coveralls3.0.2 · 1×
fs-extra7.0.0 · 1×
got10.7.0 · 1×
istanbul0.4.5 · 1×
js-beautify1.5.10 · 1×
jshint2.9.6 · 1×

For agents

$ claude mcp add nodegit \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact