0.27.0 • Published 8 days ago

nodegit v0.27.0

Weekly downloads
82,441
License
MIT
Repository
github
Last release
8 days ago

NodeGit

Node bindings to the libgit2 project.

Linux & macOSWindowsCoverageDependencies
Build Status TravisBuild Status AppVeyorCoverallsDependencies

Stable (libgit2@v0.27.3): 0.27.3

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 receive errors about lifecycleScripts preinstall/install you probably miss libssl-dev In Ubuntu:

sudo apt-get install libssl-dev

Additionally, you need curl-config on your system. You need one of these packages:

  • libcurl4-gnutls-dev
  • libcurl4-nss-dev
  • libcurl4-openssl-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");

// 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
0.28.0-alpha.26

8 days ago

0.28.0-alpha.25

11 days ago

0.28.0-alpha.24

2 months ago

0.28.0-alpha.23

2 months ago

0.28.0-alpha.22

3 months ago

0.28.0-alpha.21

1 year ago

0.28.0-alpha.20

1 year ago

0.28.0-alpha.19

1 year ago

0.28.0-alpha.17

2 years ago

0.28.0-alpha.18

2 years ago

0.28.0-alpha.15

2 years ago

0.28.0-alpha.14

2 years ago

0.28.0-alpha.16

2 years ago

0.28.0-alpha.13

2 years ago

0.28.0-alpha.12

2 years ago

0.28.0-alpha.11

2 years ago

0.28.0-alpha.10

2 years ago

0.28.0-alpha.9

3 years ago

0.28.0-alpha.7

3 years ago

0.28.0-alpha.8

3 years ago

0.28.0-alpha.6

3 years ago

0.28.0-alpha.5

3 years ago

0.28.0-alpha.4

3 years ago

0.28.0-alpha.3

3 years ago

0.28.0-alpha.2

3 years ago

0.28.0-alpha.1

3 years ago

0.27.0

4 years ago

0.27.0-alpha.1

4 years ago

0.26.5

4 years ago

0.26.4

4 years ago

0.26.3

4 years ago

0.26.2

5 years ago

0.26.1

5 years ago

0.26.0

5 years ago

0.25.1

5 years ago

0.25.0

5 years ago

0.25.0-alpha.16

5 years ago

0.25.0-alpha.15

5 years ago

0.25.0-alpha.14

5 years ago

0.25.0-alpha.13

5 years ago

0.25.0-alpha.12

5 years ago

0.25.0-alpha.11

5 years ago

0.24.3

5 years ago

0.25.0-alpha.10

5 years ago

0.24.2

5 years ago

0.25.0-alpha.9

5 years ago

0.25.0-alpha.8

5 years ago

0.25.0-alpha.7

5 years ago

0.25.0-alpha.6

5 years ago

0.24.1

5 years ago

0.23.1

5 years ago

0.25.0-alpha.5

5 years ago

0.25.0-alpha.4

5 years ago

0.25.0-alpha.3

5 years ago

0.25.0-alpha.2

5 years ago

0.25.0-alpha.1

5 years ago

0.24.0

5 years ago

0.24.0-alpha.1

6 years ago

0.23.0

6 years ago

0.23.0-alpha.2

6 years ago

0.23.0-alpha.1

6 years ago

0.22.2

6 years ago

0.22.1

6 years ago

0.22.0

6 years ago

0.21.2

6 years ago

0.21.1

6 years ago

0.21.0

6 years ago

0.20.3

7 years ago

0.20.2

7 years ago

0.20.1

7 years ago

0.20.0

7 years ago

0.18.3

7 years ago

0.18.2

7 years ago

0.18.1

7 years ago

0.19.0

7 years ago

0.18.0

7 years ago

0.17.0

7 years ago

0.16.0

8 years ago

0.14.1

8 years ago

0.15.1

8 years ago

0.15.0

8 years ago

0.14.0

8 years ago

0.13.2

8 years ago

0.13.1

8 years ago

0.13.0

8 years ago

0.12.2

8 years ago

0.12.1

8 years ago

0.12.0

8 years ago

0.11.9

8 years ago

0.11.8

8 years ago

0.11.7

8 years ago

0.11.6

8 years ago

0.11.5

8 years ago

0.11.4

8 years ago

0.11.3

8 years ago

0.11.2

8 years ago

0.11.1

8 years ago

0.11.0

8 years ago

0.10.0

8 years ago

0.9.0

8 years ago

0.8.0

8 years ago

0.7.0

8 years ago

0.6.3

8 years ago

0.6.2

8 years ago

0.0.103

8 years ago

0.0.102

8 years ago

0.0.101

8 years ago

0.6.1

8 years ago

0.6.0

8 years ago

0.0.10000005

8 years ago

0.0.10000004

8 years ago

0.0.10000003

8 years ago

0.0.10000002

8 years ago

0.0.10000001

8 years ago

0.5.0

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

11 years ago

0.0.79

11 years ago

0.0.78

11 years ago

0.0.77

11 years ago

0.0.76

11 years ago

0.0.75

11 years ago

0.0.74

11 years ago

0.0.73

11 years ago

0.0.72

11 years ago

0.0.71

11 years ago

0.0.7

11 years ago

0.0.6

12 years ago

0.0.5

13 years ago

0.0.4

13 years ago

0.0.3

13 years ago

0.0.2

13 years ago

0.0.1

13 years ago