FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Documentation · nodegit/nodegit@907b29d · GitHub

Repository navigation

Commit 907b29d

Browse files
committed
Documentation
1 parent 70bf842 commit 907b29d

16 files changed

Lines changed: 4356 additions & 2185 deletions

‎README.md‎

Lines changed: 57 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ nodegit
33

44
> Node.js libgit2 bindings
55
6-
**v0.0.78** [![Build
6+
**v0.1.0** [![Build
77
Status](https://travis-ci.org/tbranyen/nodegit.png)](https://travis-ci.org/tbranyen/nodegit)
88

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
1111
[awesome
1212
contributors](https://github.com/tbranyen/nodegit/contributors)!
1313

@@ -16,31 +16,20 @@ API Documentation
1616

1717
Documentation may be found here: [`nodegit` documentation](http://tbranyen.github.com/nodegit/).
1818

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.
3120

3221
Building and installing
3322
-----------------------
3423

3524
### 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`.
3827

3928
### Easy install (Recommended) ###
4029
This will install and configure everything you need to use `nodegit`.
4130

4231
```` bash
43-
$ npm install nodegit
32+
$ npm run-script gen && npm install && npm test
4433
````
4534

4635
### Mac OS X/Linux/Unix ###
@@ -50,14 +39,7 @@ $ npm install nodegit
5039
```` bash
5140
$ git clone git://github.com/tbranyen/nodegit.git
5241
$ 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
6143
````
6244

6345
### Windows via Cygwin ###
@@ -70,131 +52,62 @@ Instructions on compiling `Node.js` on a Windows platform can be found here:
7052
API Example Usage
7153
-----------------
7254

73-
### Git Log Emulation ###
55+
Below are two examples. [There are several more](https://github.com/nodegit/nodegit/tree/master/example).
7456

75-
#### Convenience API ####
57+
### Git Log Emulation ###
7658

7759
```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());
12478
});
79+
80+
// Don't forget to call `start()`!
81+
history.start();
12582
});
12683
});
84+
12785
```
12886

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+
```
199112

200113
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/a81b20d9f61dbcdc7c68002c6a564b5b "githalytics.com")](http://githalytics.com/tbranyen/nodegit)

‎munge.js‎

Lines changed: 0 additions & 52 deletions
This file was deleted.

‎src/blob.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ git_blob *GitBlob::GetValue() {
6969

7070

7171
/**
72-
* @return {GitOid} result
72+
* @return {Oid} result
7373
*/
7474
Handle<Value> GitBlob::Oid(const Arguments& args) {
7575
HandleScope scope;

‎src/commit.cc‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ git_commit *GitCommit::GetValue() {
7676

7777

7878
/**
79-
* @return {GitOid} result
79+
* @return {Oid} result
8080
*/
8181
Handle<Value> GitCommit::Oid(const Arguments& args) {
8282
HandleScope scope;
@@ -147,7 +147,7 @@ Handle<Value> GitCommit::Time(const Arguments& args) {
147147
}
148148

149149
/**
150-
* @return {Integer} result
150+
* @return {Number} result
151151
*/
152152
Handle<Value> GitCommit::Offset(const Arguments& args) {
153153
HandleScope scope;
@@ -163,7 +163,7 @@ Handle<Value> GitCommit::Offset(const Arguments& args) {
163163
}
164164

165165
/**
166-
* @return {GitSignature} result
166+
* @return {Signature} result
167167
*/
168168
Handle<Value> GitCommit::Committer(const Arguments& args) {
169169
HandleScope scope;
@@ -186,7 +186,7 @@ Handle<Value> GitCommit::Committer(const Arguments& args) {
186186
}
187187

188188
/**
189-
* @return {GitSignature} result
189+
* @return {Signature} result
190190
*/
191191
Handle<Value> GitCommit::Author(const Arguments& args) {
192192
HandleScope scope;
@@ -209,7 +209,7 @@ Handle<Value> GitCommit::Author(const Arguments& args) {
209209
}
210210

211211
/**
212-
* @return {GitOid} result
212+
* @return {Oid} result
213213
*/
214214
Handle<Value> GitCommit::TreeId(const Arguments& args) {
215215
HandleScope scope;
@@ -232,7 +232,7 @@ Handle<Value> GitCommit::TreeId(const Arguments& args) {
232232
}
233233

234234
/**
235-
* @return {Uint32} result
235+
* @return {Number} result
236236
*/
237237
Handle<Value> GitCommit::ParentCount(const Arguments& args) {
238238
HandleScope scope;
@@ -249,7 +249,7 @@ Handle<Value> GitCommit::ParentCount(const Arguments& args) {
249249

250250
/**
251251
* @param {Number} n
252-
* @return {GitOid} result
252+
* @return {Oid} result
253253
*/
254254
Handle<Value> GitCommit::ParentId(const Arguments& args) {
255255
HandleScope scope;

‎src/diff_list.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Handle<Value> GitDiffList::FindSimilar(const Arguments& args) {
127127
}
128128

129129
/**
130-
* @return {Uint32} result
130+
* @return {Number} result
131131
*/
132132
Handle<Value> GitDiffList::Size(const Arguments& args) {
133133
HandleScope scope;
@@ -145,7 +145,7 @@ Handle<Value> GitDiffList::Size(const Arguments& args) {
145145
/**
146146
* @param {DiffList} diff
147147
* @param {Number} type
148-
* @return {Uint32} result
148+
* @return {Number} result
149149
*/
150150
Handle<Value> GitDiffList::NumDeltasOfType(const Arguments& args) {
151151
HandleScope scope;

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL