Skip to content

Commit efb2376

Browse files
committed
Convert Clone from object to function
I find it really annoying that we have to do `NodeGit.Clone.clone` just to clone a repository. It would be much nicer to get a similar effect like in C, where you can run `git_clone`. This copies over the effect of an object, but actually using our `clone` patched function instead. I've made this commit first to show it does not introduce regressions with our current clone code.
1 parent ee85185 commit efb2376

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/clone.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,10 @@ Clone.clone = function(url, local_path, options) {
4545
.then(openRepository);
4646
};
4747

48-
module.exports = Clone;
48+
// Inherit directly from the original clone object.
49+
Clone.clone.__proto__ = Clone;
50+
51+
// Ensure we're using the correct prototype.
52+
Clone.clone.prototype = Clone.prototype;
53+
54+
module.exports = Clone.clone;

0 commit comments

Comments
 (0)