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

round 3 trying new readme syntax highlighting · javascript-forks/nodegit.nodegit@d50616d · GitHub

Repository navigation

Commit d50616d

Browse files
committed
round 3 trying new readme syntax highlighting
1 parent 4396864 commit d50616d

2 files changed

Lines changed: 94 additions & 88 deletions

File tree

‎README.md‎

Lines changed: 93 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ To run `nodegit` you need `Node.js` and to run unit tests you will need to have
1414
### Easy install (Recommended) ###
1515
This will install and configure everything you need to use `nodegit`.
1616

17-
$ sudo npm install nodegit
17+
```` bash
18+
$ sudo npm install nodegit
19+
````
1820

1921
To update an existing installation, run
2022

@@ -54,121 +56,125 @@ API Example Usage
5456

5557
#### Convenience API ####
5658

57-
var git = require( 'nodegit' );
58-
59-
// Read a repository
60-
git.repo( '.git', function( err, repo ) {
61-
// Success is always 0, failure is always an error string
59+
```` javascript
60+
var git = require( 'nodegit' );
61+
62+
// Read a repository
63+
git.repo( '.git', function( err, repo ) {
64+
// Success is always 0, failure is always an error string
65+
if( err ) { throw err; }
66+
67+
// Use the master branch
68+
repo.branch( 'master', function( err, branch ) {
6269
if( err ) { throw err; }
6370

64-
// Use the master branch
65-
repo.branch( 'master', function( err, branch ) {
66-
if( err ) { throw err; }
67-
68-
// Iterate over the revision history
69-
var history = branch.history();
70-
71-
// Commit event is emitted with index 0,n... and commit object
72-
history.on( 'commit', function( idx, commit ) {
73-
// Print out `git log` emulation
74-
console.log( 'commit ' + commit.sha );
75-
console.log( commit.author.name + '<' + commit.author.email + '>' );
76-
console.log( commit.time );
77-
console.log( '\n' );
78-
console.log( commit.message );
79-
console.log( '\n' );
80-
});
71+
// Iterate over the revision history
72+
var history = branch.history();
73+
74+
// Commit event is emitted with index 0,n... and commit object
75+
history.on( 'commit', function( idx, commit ) {
76+
// Print out `git log` emulation
77+
console.log( 'commit ' + commit.sha );
78+
console.log( commit.author.name + '<' + commit.author.email + '>' );
79+
console.log( commit.time );
80+
console.log( '\n' );
81+
console.log( commit.message );
82+
console.log( '\n' );
8183
});
8284
});
85+
});
86+
````
8387

8488
#### Raw API ####
8589

86-
var git = require( 'nodegit' ).raw;
87-
88-
// Create instance of Repo constructor
89-
var repo = new git.Repo();
90+
```` javascript
91+
var git = require( 'nodegit' ).raw;
92+
93+
// Create instance of Repo constructor
94+
var repo = new git.Repo();
9095

91-
// Read a repository
92-
repo.open( '.git', function( err ) {
93-
// Err is an integer, success is 0, use strError for string representation
96+
// Read a repository
97+
repo.open( '.git', function( err ) {
98+
// Err is an integer, success is 0, use strError for string representation
99+
if( err ) {
100+
var error = new git.Error();
101+
throw error.strError( err );
102+
}
103+
104+
// Create instance of Ref constructor with this repository
105+
var ref = new git.Ref( repo );
106+
107+
// Find the master branch
108+
repo.lookupRef( ref, '/refs/heads/master', function( err ) {
94109
if( err ) {
95-
var error = new git.Error();
96-
throw error.strError( err );
110+
var error = new git.Error();
111+
throw error.strError( err );
97112
}
98113

99-
// Create instance of Ref constructor with this repository
100-
var ref = new git.Ref( repo );
101-
102-
// Find the master branch
103-
repo.lookupRef( ref, '/refs/heads/master', function( err ) {
114+
// Create instance of Commit constructor with this repository
115+
var commit = new git.Commit( repo ),
116+
// Create instance of Oid constructor
117+
oid = new git.Oid();
118+
119+
// Set the oid constructor internal reference to this branch reference
120+
ref.oid( oid );
121+
122+
// Lookup the commit for this oid
123+
commit.lookup( oid, function() {
104124
if( err ) {
105125
var error = new git.Error();
106126
throw error.strError( err );
107127
}
108128

109-
// Create instance of Commit constructor with this repository
110-
var commit = new git.Commit( repo ),
111-
// Create instance of Oid constructor
112-
oid = new git.Oid();
113-
114-
// Set the oid constructor internal reference to this branch reference
115-
ref.oid( oid );
129+
// Create instance of RevWalk constructor with this repository
130+
var revwalk = new git.RevWalk( repo );
116131

117-
// Lookup the commit for this oid
118-
commit.lookup( oid, function() {
119-
if( err ) {
120-
var error = new git.Error();
121-
throw error.strError( err );
122-
}
132+
// Push the commit as the start to walk
133+
revwalk.push( commit );
123134

124-
// Create instance of RevWalk constructor with this repository
125-
var revwalk = new git.RevWalk( repo );
135+
// Recursive walk
136+
function walk() {
137+
// Each revision walk iteration yields a commit
138+
var revisionCommit = new git.Commit( repo );
126139

127-
// Push the commit as the start to walk
128-
revwalk.push( commit );
140+
revwalk.next( revisionCommit, function( err ) {
141+
// Finish recursion once no more revision commits are left
142+
if( err ) { return; }
129143

130-
// Recursive walk
131-
function walk() {
132-
// Each revision walk iteration yields a commit
133-
var revisionCommit = new git.Commit( repo );
144+
// Create instance of Oid for sha
145+
var oid = new git.Oid();
134146

135-
revwalk.next( revisionCommit, function( err ) {
136-
// Finish recursion once no more revision commits are left
137-
if( err ) { return; }
147+
// Set oid to the revision commit
148+
revisionCommit.id( oid );
138149

139-
// Create instance of Oid for sha
140-
var oid = new git.Oid();
150+
// Create instance of Sig for author
151+
var author = new git.Sig();
141152

142-
// Set oid to the revision commit
143-
revisionCommit.id( oid );
153+
// Set the author to the revision commit author
154+
revisionCommit.author( author );
144155

145-
// Create instance of Sig for author
146-
var author = new git.Sig();
156+
// Convert timestamp to milliseconds and set new Date object
157+
var time = new Date( revisionCommit.time() * 1000 );
147158

148-
// Set the author to the revision commit author
149-
revisionCommit.author( author );
159+
// Print out `git log` emulation
160+
console.log( oid.toString( 40 ) );
161+
console.log( author.name() + '<' + author.email() + '>' );
162+
console.log( time );
163+
console.log( '\n' );
164+
console.log( revisionCommit.message() );
165+
console.log( '\n' );
150166

151-
// Convert timestamp to milliseconds and set new Date object
152-
var time = new Date( revisionCommit.time() * 1000 );
153-
154-
// Print out `git log` emulation
155-
console.log( oid.toString( 40 ) );
156-
console.log( author.name() + '<' + author.email() + '>' );
157-
console.log( time );
158-
console.log( '\n' );
159-
console.log( revisionCommit.message() );
160-
console.log( '\n' );
161-
162-
// Recurse!
163-
walk();
164-
});
165-
}
167+
// Recurse!
168+
walk();
169+
});
170+
}
166171

167-
// Initiate recursion
168-
walk():
169-
});
172+
// Initiate recursion
173+
walk():
170174
});
171175
});
176+
});
177+
````
172178

173179
Running tests
174180
-------------

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL