Skip to content

Commit 316f4ce

Browse files
author
John Haley
committed
Updated the clone example
1 parent 1f173a4 commit 316f4ce

1 file changed

Lines changed: 25 additions & 23 deletions

File tree

example/clone.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1-
var git = require('../'),
2-
rimraf = require('rimraf'),
3-
path = "/tmp/nodegit-clone-demo";
1+
var git = require('../');
2+
var rimraf = require('rimraf');
3+
var path = "/tmp/nodegit-clone-demo";
44

55
rimraf(path, function() {
6-
git.Repo.clone("https://github.com/nodegit/nodegit.git", path, null, function(error, repo) {
7-
if (error) throw error;
6+
var entry;
87

9-
repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5', function(error, commit) {
10-
if (error) throw error;
11-
12-
commit.getEntry('README.md', function(error, entry) {
13-
if (error) throw error;
14-
15-
entry.getBlob(function(error, blob) {
16-
if (error) throw error;
17-
18-
console.log(entry.name(), entry.sha(), blob.size() + 'b');
19-
console.log('========================================================\n\n');
20-
var firstTenLines = blob.toString().split('\n').slice(0, 10).join('\n');
21-
console.log(firstTenLines);
22-
console.log('...');
23-
});
24-
});
25-
});
8+
git.Clone.clone(
9+
"https://github.com/nodegit/nodegit.git",
10+
path,
11+
{ ignoreCertErrors: 1})
12+
.then(function(repo) {
13+
return repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5');
14+
})
15+
.then(function(commit) {
16+
return commit.getEntry('README.md')
17+
})
18+
.then(function(entryResult) {
19+
entry = entryResult;
20+
return entry.getBlob();
21+
})
22+
.done(function(blob) {
23+
console.log(entry.filename(), entry.sha(), blob.rawsize() + 'b');
24+
console.log('========================================================\n\n');
25+
var firstTenLines = blob.toString().split('\n').slice(0, 10).join('\n');
26+
console.log(firstTenLines);
27+
console.log('...');
2628
});
27-
});
29+
});

0 commit comments

Comments
 (0)