diff --git a/examples/checkout-remote-branch.js b/examples/checkout-remote-branch.js new file mode 100644 index 000000000..4ebf9050b --- /dev/null +++ b/examples/checkout-remote-branch.js @@ -0,0 +1,26 @@ +var nodegit = require("../"); +var path = require("path"); + +var remoteBranchName = "REMOTE-BRANCH-NAME"; + +nodegit.Repository.open(path.resolve(__dirname, "../.git")) + .then(function(repo) { + + return repo.getHeadCommit() + .then(function (targetCommit) { + return repo.createBranch(remoteBranchName, targetCommit, false); + }) + .then(function (reference) { + return repo.checkoutBranch(reference, {}); + }) + .then(function () { + return repo.getReferenceCommit( + "refs/remotes/origin/" + remoteBranchName); + }) + .then(function (commit) { + nodegit.Reset.reset(repo, commit, 3, {}); + }); + + }).done(function() { + console.log("All done!"); +}); diff --git a/guides/cloning/README.md b/guides/cloning/README.md index 7a44d0cf6..2b1fa508a 100644 --- a/guides/cloning/README.md +++ b/guides/cloning/README.md @@ -112,7 +112,7 @@ a function to attempt opening in this case. ``` javascript var errorAndAttemptOpen = function() { - return NodeGit.Repository.open(local); + return NodeGit.Repository.open(localPath); }; ``` diff --git a/guides/cloning/gh-two-factor/README.md b/guides/cloning/gh-two-factor/README.md index 1a9190ab3..a3b8bbb3f 100644 --- a/guides/cloning/gh-two-factor/README.md +++ b/guides/cloning/gh-two-factor/README.md @@ -149,7 +149,7 @@ a function to attempt opening in this case. ``` javascript var errorAndAttemptOpen = function() { - return NodeGit.Repository.open(local); + return NodeGit.Repository.open(localPath); }; ``` diff --git a/guides/cloning/ssh-with-agent/README.md b/guides/cloning/ssh-with-agent/README.md index ae14cfe39..b2cfbe8ce 100644 --- a/guides/cloning/ssh-with-agent/README.md +++ b/guides/cloning/ssh-with-agent/README.md @@ -137,7 +137,7 @@ a function to attempt opening in this case. ``` javascript var errorAndAttemptOpen = function() { - return NodeGit.Repository.open(local); + return NodeGit.Repository.open(localPath); }; ``` diff --git a/lib/reference.js b/lib/reference.js index 8cfdded6c..821ace32f 100644 --- a/lib/reference.js +++ b/lib/reference.js @@ -34,7 +34,7 @@ Reference.prototype.isConcrete = function() { /** * Returns if the ref is pointed at by HEAD - * @return {bool} + * @return {Boolean} */ Reference.prototype.isHead = function() { return Branch.isHead(this); diff --git a/lib/repository.js b/lib/repository.js index 01dbfff59..6f262a667 100644 --- a/lib/repository.js +++ b/lib/repository.js @@ -495,7 +495,7 @@ Repository.prototype.continueRebase = function( * @async * @param {String} name Branch name, e.g. "master" * @param {Commit|String|Oid} commit The commit the branch will point to - * @param {bool} force Overwrite branch if it exists + * @param {Boolean} force Overwrite branch if it exists * @return {Reference} */ Repository.prototype.createBranch = function(name, commit, force) { diff --git a/lib/reset.js b/lib/reset.js index df770304a..18a7ebfe1 100644 --- a/lib/reset.js +++ b/lib/reset.js @@ -22,7 +22,7 @@ Reset.default = function(repo, target, pathspecs) { }; /** - * Look up a refs's commit. + * Reset a repository's current HEAD to the specified target. * * @async * @param {Repository} repo Repository where to perform the reset operation. @@ -41,9 +41,6 @@ Reset.default = function(repo, target, pathspecs) { * used to propagate notify and progress * callbacks. * - * @param {String|Ref} name Ref name, e.g. "master", "refs/heads/master" - * or Branch Ref - * * @return {Number} 0 on success or an error code */ Reset.reset = function(repo, target, resetType, opts) {