| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,11 +3,11 @@ nodegit | |||
| 3 | 3 | ||
| 4 | 4 | > Node.js libgit2 bindings | |
| 5 | 5 | ||
| 6 | - **v0.0.78** [](https://travis-ci.org/tbranyen/nodegit) | |
| 8 | 8 | ||
| 9 | - Maintained by Tim Branyen [@tbranyen](http://twitter.com/tbranyen) and Michael | ||
| 10 | - Robinson [@codeofinterest](http://twitter.com/codeofinterest), with help from | ||
| 9 | + Maintained by Tim Branyen [@tbranyen](http://twitter.com/tbranyen), Michael | ||
| 10 | + Robinson [@codeofinterest](http://twitter.com/codeofinterest), and Nick Kallen [@nk](http://twitter.com/nk), with help from | ||
| 11 | 11 | [awesome | |
| 12 | 12 | contributors](https://github.com/tbranyen/nodegit/contributors)! | |
| 13 | 13 | ||
@@ -16,31 +16,20 @@ API Documentation | |||
| 16 | 16 | ||
| 17 | 17 | Documentation may be found here: [`nodegit` documentation](http://tbranyen.github.com/nodegit/). | |
| 18 | 18 | ||
| 19 | - Contributing | ||
| 20 | - ------------ | ||
| 21 | - | ||
| 22 | - Nodegit aims to eventually provide native asynchronous bindings for as much of | ||
| 23 | - libgit2 as possible, but we can't do it alone! | ||
| 24 | - | ||
| 25 | - We welcome pull requests, but please pay attention to the following: whether | ||
| 26 | - your lovely code fixes a bug or adds a new feature, please include unit tests | ||
| 27 | - that either prove the bug is fixed, or that your new feature works as expected. | ||
| 28 | - See [running tests](#running-tests) | ||
| 29 | - | ||
| 30 | - Unit tests are what makes the Node event loop go around. | ||
| 19 | + Nodegit aims to eventually provide native asynchronous bindings for as much of libgit2 as possible. | ||
| 31 | 20 | ||
| 32 | 21 | Building and installing | |
| 33 | 22 | ----------------------- | |
| 34 | 23 | ||
| 35 | 24 | ### Dependencies ### | |
| 36 | - To install `nodegit` you need `Node.js`, `python` and `cmake`. To run unit tests you will need to have | ||
| 37 | - `git` installed and accessible from your `PATH` to fetch any `vendor/` addons. | ||
| 25 | + | ||
| 26 | + To install `nodegit` you need `Node.js`, `python` and `cmake`. | ||
| 38 | 27 | ||
| 39 | 28 | ### Easy install (Recommended) ### | |
| 40 | 29 | This will install and configure everything you need to use `nodegit`. | |
| 41 | 30 | ||
| 42 | 31 | ```` bash | |
| 43 | - $ npm install nodegit | ||
| 32 | + $ npm run-script gen && npm install && npm test | ||
| 44 | 33 | ```` | |
| 45 | 34 | ||
| 46 | 35 | ### Mac OS X/Linux/Unix ### | |
@@ -50,14 +39,7 @@ $ npm install nodegit | |||
| 50 | 39 | ```` bash | |
| 51 | 40 | $ git clone git://github.com/tbranyen/nodegit.git | |
| 52 | 41 | $ cd nodegit | |
| 53 | - $ node install | ||
| 54 | - ```` | ||
| 55 | - | ||
| 56 | - \*Updating to a new version\* | ||
| 57 | - | ||
| 58 | - ```` bash | ||
| 59 | - $ git pull | ||
| 60 | - $ node install | ||
| 42 | + $ npm run-script gen && npm install | ||
| 61 | 43 | ```` | |
| 62 | 44 | ||
| 63 | 45 | ### Windows via Cygwin ### | |
@@ -70,131 +52,62 @@ Instructions on compiling `Node.js` on a Windows platform can be found here: | |||
| 70 | 52 | API Example Usage | |
| 71 | 53 | ----------------- | |
| 72 | 54 | ||
| 73 | - ### Git Log Emulation ### | ||
| 55 | + Below are two examples. [There are several more](https://github.com/nodegit/nodegit/tree/master/example). | ||
| 74 | 56 | ||
| 75 | - #### Convenience API #### | ||
| 57 | + ### Git Log Emulation ### | ||
| 76 | 58 | ||
| 77 | 59 | ```JavaScript | |
| 78 | - // Load in the module. | ||
| 79 | - var git = require('nodegit'), | ||
| 80 | - async = require('async'); | ||
| 81 | - | ||
| 82 | - // Open the repository in the current directory. | ||
| 83 | - git.repo('.git', function(error, repository) { | ||
| 84 | - if (error) { | ||
| 85 | - throw error; | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | - // Use the master branch. | ||
| 89 | - repository.branch('master', function(error, branch) { | ||
| 90 | - if (error) { | ||
| 91 | - throw error; | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | - // Iterate over the revision history. | ||
| 95 | - branch.history().on('commit', function(error, commit) { | ||
| 96 | - | ||
| 97 | - // Print out `git log` emulation. | ||
| 98 | - async.series([ | ||
| 99 | - function(callback) { | ||
| 100 | - commit.sha(callback); | ||
| 101 | - }, | ||
| 102 | - function(callback) { | ||
| 103 | - commit.time(callback); | ||
| 104 | - }, | ||
| 105 | - function(callback) { | ||
| 106 | - commit.author(function(error, author) { | ||
| 107 | - author.name(callback); | ||
| 108 | - }); | ||
| 109 | - }, | ||
| 110 | - function(callback) { | ||
| 111 | - commit.author(function(error, author) { | ||
| 112 | - author.email(callback); | ||
| 113 | - }); | ||
| 114 | - }, | ||
| 115 | - function(callback) { | ||
| 116 | - commit.message(callback); | ||
| 117 | - } | ||
| 118 | - ], function printCommit(error, results) { | ||
| 119 | - console.log('SHA ' + results[0]); | ||
| 120 | - console.log(new Date(results[1] * 1000)); | ||
| 121 | - console.log(results[2] + ' <' + results[3] + '>'); | ||
| 122 | - console.log(results[4]); | ||
| 123 | - }); | ||
| 60 | + var git = require('../'), | ||
| 61 | + path = require('path'); | ||
| 62 | + | ||
| 63 | + git.Repo.open(path.resolve(__dirname, '/tmp/repo/.git'), function(error, repo) { | ||
| 64 | + if (error) throw error; | ||
| 65 | + | ||
| 66 | + repo.getMaster(function(error, branch) { | ||
| 67 | + if (error) throw error; | ||
| 68 | + | ||
| 69 | + // History returns an event. | ||
| 70 | + var history = branch.history(); | ||
| 71 | + | ||
| 72 | + // History emits 'commit' event for each commit in the branch's history | ||
| 73 | + history.on('commit', function(commit) { | ||
| 74 | + console.log('commit ' + commit.sha()); | ||
| 75 | + console.log('Author:', commit.author().name() + ' <' + commit.author().email() + '>'); | ||
| 76 | + console.log('Date:', commit.date()); | ||
| 77 | + console.log('\n ' + commit.message()); | ||
| 124 | 78 | }); | |
| 79 | + | ||
| 80 | + // Don't forget to call `start()`! | ||
| 81 | + history.start(); | ||
| 125 | 82 | }); | |
| 126 | 83 | }); | |
| 84 | + | ||
| 127 | 85 | ``` | |
| 128 | 86 | ||
| 129 | - Running tests | ||
| 130 | - ------------- | ||
| 131 | - | ||
| 132 | - __`nodegit` library code is written adhering to a modified `JSHint`. Run these checks with `make lint` in the project root.__ | ||
| 133 | - | ||
| 134 | - __To run unit tests ensure to update the submodules with `git submodule update --init` and install the development dependencies nodeunit and rimraf with `npm install`.__ | ||
| 135 | - | ||
| 136 | - Then simply run `npm test` in the project root. | ||
| 137 | - | ||
| 138 | - Release information | ||
| 139 | - ------------------- | ||
| 140 | - | ||
| 141 | - __Can keep track of current method coverage at: [http://bit.ly/tb_methods](http://bit.ly/tb_methods)__ | ||
| 142 | - | ||
| 143 | - ### v0.0.7: ### | ||
| 144 | - * Updated to work with Node ~0.8. | ||
| 145 | - * More unit tests | ||
| 146 | - * Added convenience build script | ||
| 147 | - * Locked libgit2 to version 0.15.0 | ||
| 148 | - | ||
| 149 | - ### v0.0.6: ### | ||
| 150 | - * Updated to work with Node ~0.6. | ||
| 151 | - | ||
| 152 | - ### v0.0.5: ### | ||
| 153 | - * Added in fast Buffer support. | ||
| 154 | - * Blob raw write supported added, no convenience methods yet... | ||
| 155 | - * Updated libgit2 to version 0.12.0 | ||
| 156 | - | ||
| 157 | - ### v0.0.4: ### | ||
| 158 | - * Many fixes! | ||
| 159 | - * Blob raw write supported added, no convenience methods yet... | ||
| 160 | - * Updated libgit2 to version 0.12.0 | ||
| 161 | - | ||
| 162 | - ### v0.0.3: ### | ||
| 163 | - * More documented native source code | ||
| 164 | - * Updated convenience api code | ||
| 165 | - * More unit tests | ||
| 166 | - * Updated libgit2 to version 0.11.0 | ||
| 167 | - * Windows Cygwin support! *albeit hacky* | ||
| 168 | - | ||
| 169 | - ### v0.0.2: ### | ||
| 170 | - * More methods implemented | ||
| 171 | - * More unit tests | ||
| 172 | - * More API development | ||
| 173 | - * Tree and Blob support | ||
| 174 | - * Updated libgit2 to version 0.8.0 | ||
| 175 | - | ||
| 176 | - ### v0.0.1: ### | ||
| 177 | - * Some useful methods implemented | ||
| 178 | - * Some unit tests | ||
| 179 | - * Some documented source code | ||
| 180 | - * Useable build/code quality check tools | ||
| 181 | - * Node.js application that can be configured/built/installed via source and NPM | ||
| 182 | - * An API that can be easily extended with convenience methods in JS | ||
| 183 | - * An API that offers a familiar clean syntax that will make adoption and use much more likely | ||
| 184 | - * Open for public testing | ||
| 185 | - * GitHub landing page | ||
| 186 | - * Repo, Oid, Commit, Error, Ref, and RevWalk support | ||
| 187 | - * Built on libgit2 version 0.3.0 | ||
| 188 | - | ||
| 189 | - Getting involved | ||
| 190 | - ---------------- | ||
| 191 | - | ||
| 192 | - If you find this project of interest, please document all issues and fork if | ||
| 193 | - you feel you can provide a patch. Testing is of huge importance; by simply | ||
| 194 | - running the unit tests on your system and reporting issues you can contribute! | ||
| 195 | - | ||
| 196 | - __Before submitting a pull request, please ensure both that you've added unit | ||
| 197 | - tests to cover your shiny new code, and that all unit tests and lint checks | ||
| 198 | - pass.__ | ||
| 87 | + ### Clone a repo and read a file ### | ||
| 88 | + | ||
| 89 | + ```JavaScript | ||
| 90 | + git.Repo.clone("https://github.com/nodegit/nodegit.git", path, null, function(error, repo) { | ||
| 91 | + if (error) throw error; | ||
| 92 | + | ||
| 93 | + repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5', function(error, commit) { | ||
| 94 | + if (error) throw error; | ||
| 95 | + | ||
| 96 | + commit.getEntry('README.md', function(error, entry) { | ||
| 97 | + if (error) throw error; | ||
| 98 | + | ||
| 99 | + entry.getBlob(function(error, blob) { | ||
| 100 | + if (error) throw error; | ||
| 101 | + | ||
| 102 | + console.log(entry.name(), entry.sha(), blob.size() + 'b'); | ||
| 103 | + console.log('========================================================\n\n'); | ||
| 104 | + var firstTenLines = blob.toString().split('\n').slice(0, 10).join('\n'); | ||
| 105 | + console.log(firstTenLines); | ||
| 106 | + console.log('...'); | ||
| 107 | + }); | ||
| 108 | + }); | ||
| 109 | + }); | ||
| 110 | + }); | ||
| 111 | + ``` | ||
| 199 | 112 | ||
| 200 | 113 | [](http://githalytics.com/tbranyen/nodegit) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,7 +69,7 @@ git_blob *GitBlob::GetValue() { | |||
| 69 | 69 | ||
| 70 | 70 | ||
| 71 | 71 | /** | |
| 72 | - * @return {GitOid} result | ||
| 72 | + * @return {Oid} result | ||
| 73 | 73 | */ | |
| 74 | 74 | Handle<Value> GitBlob::Oid(const Arguments& args) { | |
| 75 | 75 | HandleScope scope; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,7 +76,7 @@ git_commit *GitCommit::GetValue() { | |||
| 76 | 76 | ||
| 77 | 77 | ||
| 78 | 78 | /** | |
| 79 | - * @return {GitOid} result | ||
| 79 | + * @return {Oid} result | ||
| 80 | 80 | */ | |
| 81 | 81 | Handle<Value> GitCommit::Oid(const Arguments& args) { | |
| 82 | 82 | HandleScope scope; | |
@@ -147,7 +147,7 @@ Handle<Value> GitCommit::Time(const Arguments& args) { | |||
| 147 | 147 | } | |
| 148 | 148 | ||
| 149 | 149 | /** | |
| 150 | - * @return {Integer} result | ||
| 150 | + * @return {Number} result | ||
| 151 | 151 | */ | |
| 152 | 152 | Handle<Value> GitCommit::Offset(const Arguments& args) { | |
| 153 | 153 | HandleScope scope; | |
@@ -163,7 +163,7 @@ Handle<Value> GitCommit::Offset(const Arguments& args) { | |||
| 163 | 163 | } | |
| 164 | 164 | ||
| 165 | 165 | /** | |
| 166 | - * @return {GitSignature} result | ||
| 166 | + * @return {Signature} result | ||
| 167 | 167 | */ | |
| 168 | 168 | Handle<Value> GitCommit::Committer(const Arguments& args) { | |
| 169 | 169 | HandleScope scope; | |
@@ -186,7 +186,7 @@ Handle<Value> GitCommit::Committer(const Arguments& args) { | |||
| 186 | 186 | } | |
| 187 | 187 | ||
| 188 | 188 | /** | |
| 189 | - * @return {GitSignature} result | ||
| 189 | + * @return {Signature} result | ||
| 190 | 190 | */ | |
| 191 | 191 | Handle<Value> GitCommit::Author(const Arguments& args) { | |
| 192 | 192 | HandleScope scope; | |
@@ -209,7 +209,7 @@ Handle<Value> GitCommit::Author(const Arguments& args) { | |||
| 209 | 209 | } | |
| 210 | 210 | ||
| 211 | 211 | /** | |
| 212 | - * @return {GitOid} result | ||
| 212 | + * @return {Oid} result | ||
| 213 | 213 | */ | |
| 214 | 214 | Handle<Value> GitCommit::TreeId(const Arguments& args) { | |
| 215 | 215 | HandleScope scope; | |
@@ -232,7 +232,7 @@ Handle<Value> GitCommit::TreeId(const Arguments& args) { | |||
| 232 | 232 | } | |
| 233 | 233 | ||
| 234 | 234 | /** | |
| 235 | - * @return {Uint32} result | ||
| 235 | + * @return {Number} result | ||
| 236 | 236 | */ | |
| 237 | 237 | Handle<Value> GitCommit::ParentCount(const Arguments& args) { | |
| 238 | 238 | HandleScope scope; | |
@@ -249,7 +249,7 @@ Handle<Value> GitCommit::ParentCount(const Arguments& args) { | |||
| 249 | 249 | ||
| 250 | 250 | /** | |
| 251 | 251 | * @param {Number} n | |
| 252 | - * @return {GitOid} result | ||
| 252 | + * @return {Oid} result | ||
| 253 | 253 | */ | |
| 254 | 254 | Handle<Value> GitCommit::ParentId(const Arguments& args) { | |
| 255 | 255 | HandleScope scope; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -127,7 +127,7 @@ Handle<Value> GitDiffList::FindSimilar(const Arguments& args) { | |||
| 127 | 127 | } | |
| 128 | 128 | ||
| 129 | 129 | /** | |
| 130 | - * @return {Uint32} result | ||
| 130 | + * @return {Number} result | ||
| 131 | 131 | */ | |
| 132 | 132 | Handle<Value> GitDiffList::Size(const Arguments& args) { | |
| 133 | 133 | HandleScope scope; | |
@@ -145,7 +145,7 @@ Handle<Value> GitDiffList::Size(const Arguments& args) { | |||
| 145 | 145 | /** | |
| 146 | 146 | * @param {DiffList} diff | |
| 147 | 147 | * @param {Number} type | |
| 148 | - * @return {Uint32} result | ||
| 148 | + * @return {Number} result | ||
| 149 | 149 | */ | |
| 150 | 150 | Handle<Value> GitDiffList::NumDeltasOfType(const Arguments& args) { | |
| 151 | 151 | HandleScope scope; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments