Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated the clone example
  • Loading branch information
John Haley committed Nov 14, 2014
commit 316f4ce522fd70871695709aafd88e39a31d7ef2
48 changes: 25 additions & 23 deletions example/clone.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
var git = require('../'),
rimraf = require('rimraf'),
path = "/tmp/nodegit-clone-demo";
var git = require('../');
var rimraf = require('rimraf');
var path = "/tmp/nodegit-clone-demo";

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

repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5', function(error, commit) {
if (error) throw error;

commit.getEntry('README.md', function(error, entry) {
if (error) throw error;

entry.getBlob(function(error, blob) {
if (error) throw error;

console.log(entry.name(), entry.sha(), blob.size() + 'b');
console.log('========================================================\n\n');
var firstTenLines = blob.toString().split('\n').slice(0, 10).join('\n');
console.log(firstTenLines);
console.log('...');
});
});
});
git.Clone.clone(
"https://github.com/nodegit/nodegit.git",
path,
{ ignoreCertErrors: 1})
.then(function(repo) {
return repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5');
})
.then(function(commit) {
return commit.getEntry('README.md')
})
.then(function(entryResult) {
entry = entryResult;
return entry.getBlob();
})
.done(function(blob) {
console.log(entry.filename(), entry.sha(), blob.rawsize() + 'b');
console.log('========================================================\n\n');
var firstTenLines = blob.toString().split('\n').slice(0, 10).join('\n');
console.log(firstTenLines);
console.log('...');
});
});
});