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

Adds in git_checkout_tree by tbranyen · Pull Request #402 · nodegit/nodegit · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (2) .json  (1) All 2 file types 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
13 changes: 12 additions & 1 deletion generate/input/descriptor.json
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 @@ -199,7 +199,18 @@
"ignore": true
},
"git_checkout_tree": {
"ignore": true
"args": {
"treeish": {
"isOptional": true
},
"opts": {
"isOptional": true
}
},
"isAsync": true,
"return": {
"isErrorCode": true
}
}
}
},
Expand Down
15 changes: 14 additions & 1 deletion lib/checkout.js
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 @@ -3,11 +3,12 @@ var normalizeOptions = require("./util/normalize_options");

var Checkout = NodeGit.Checkout;
var head = Checkout.head;
var tree = Checkout.tree;

/**
* Patch head checkout to automatically coerce objects.
*
* @param repo
* @param url
* @param options
*/
Checkout.head = function(url, options) {
Expand All @@ -16,5 +17,17 @@ Checkout.head = function(url, options) {
return head.call(this, url, options);
};

/**
* Patch tree checkout to automatically coerce objects.
*
* @param repo
* @param treeish
* @param options
*/
Checkout.tree = function(repo, treeish, options) {
options = normalizeOptions(options, NodeGit.CheckoutOptions);

return tree.call(this, repo, treeish, options);
};

module.exports = Checkout;
12 changes: 12 additions & 0 deletions test/tests/checkout.js
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 @@ -31,4 +31,16 @@ describe("Checkout", function() {
assert.ok(~packageJson.indexOf("\"ejs\": \"~1.0.0\","));
});
});

it("can checkout by tree", function() {
var test = this;

return test.repo.getTagByName("annotated-tag").then(function(tag) {
return Checkout.tree(test.repo, test.tag);
}).then(function() {
return test.repo.getHeadCommit();
}).then(function(commit) {
assert.equal(commit, "32789a79e71fbc9e04d3eff7425e1771eb595150");
});
});
});

Back | FazBrowse Home | New Git URL