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

Update Readme, to improve example code by nmn · Pull Request #248 · nodegit/nodegit · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .md  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
54 changes: 30 additions & 24 deletions README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,32 @@ npm install nodegit --msvs_version=2013
var clone = require("nodegit").Repository.clone;

// Clone a given repository into a specific folder.
clone("https://github.com/nodegit/nodegit", "tmp", null).then(function(repo) {
// Use a known commit sha from this repository.
var sha = "59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5";

// Look up this known commit.
repo.getCommit(sha).then(function(commit) {
clone("https://github.com/nodegit/nodegit", "tmp", null)
.then(function(repo) {
// Use a known commit sha from this repository.
var sha = "59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5";

// Look up this known commit.
return repo.getCommit(sha);
})
.then(function(commit) {
// Look up a specific file within that commit.
commit.getEntry("README.md").then(function(entry) {
// Get the blob contents from the file.
entry.getBlob().then(function(blob) {
// Show the name, sha, and filesize in byes.
console.log(entry.name() + entry.sha() + blob.size() + "b");

// Show a spacer.
console.log(Array(72).join("=") + "\n\n");

// Show the entire file.
console.log(String(blob));
});
});
return commit.getEntry("README.md");
})
.then(function(entry) {
// Get the blob contents from the file.
return entry.getBlob();
})
.then(function(blob) {
// Show the name, sha, and filesize in byes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks like some extra space here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

There were some lines already, I left extra spaces before every comment. That's just a style choice. You can make the call.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nope, if you look at the diff the comment aligned with console. Now it's off by a few. Sorry if I wasn't clear.

console.log(entry.name() + entry.sha() + blob.size() + "b");

// Show a spacer.
console.log(Array(72).join("=") + "\n\n");

// Show the entire file.
console.log(String(blob));
});
});
```

### Emulating git log: ###
Expand All @@ -130,9 +134,12 @@ clone("https://github.com/nodegit/nodegit", "tmp", null).then(function(repo) {
var open = require("nodegit").Repository.open;

// Open the repository directory.
open("tmp").then(function(repo) {
// Open the master branch.
repo.getMaster().then(function(branch) {
open("tmp")
.then(function(repo) {
// Open the master branch.
return repo.getMaster();
})
.then(function(branch) {
// Create a new history event emitter.
var history = branch.history();

Expand Down Expand Up @@ -165,7 +172,6 @@ open("tmp").then(function(repo) {
// Start emitting events.
history.start();
});
});
```

## Unit tests. ##
Expand Down

Back | FazBrowse Home | New Git URL