Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions generate/scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ var Helpers = {
}
}).value();

if ("git_" + typeDef.typeName == fnDef.cFunctionName) {
fnDef.useAsOnRootProto = true;
}
_.merge(fnDef, _.omit(fnOverrides, "args", "return"));
},

Expand Down
3 changes: 2 additions & 1 deletion generate/templates/templates/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ NodeGit.Enums = {};
{% each . as enumerable %}
{% if not enumerable.ignore %}
{% if enumerable.type == "enum" %}
NodeGit.{{ enumerable.owner }}.{{ enumerable.JsName }} = {
NodeGit.{{ enumerable.owner }}.{{ enumerable.JsName }} =
NodeGit.{{ enumerable.owner }}.__proto__.{{ enumerable.JsName }} = {
{% each enumerable.values as value %}
{{ value.JsName }}: {{ value.value }},
{% endeach %}
Expand Down
42 changes: 39 additions & 3 deletions generate/templates/templates/nodegit.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,54 @@ exports.__proto__ = rawApi;
var importExtension = function(name) {
try {
require("./" + name);
} catch (unhandledException) {}
}
catch (unhandledException) {
if (unhandledException.code != "MODULE_NOT_FOUND") {
Copy link
Member

Choose a reason for hiding this comment

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

Good call! This would have trapped errors inside the modules before.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, You'll never guess how I found that hahaha

throw unhandledException;
}
}
};

// Load up utils
rawApi.Utils = {};
require("./utils/lookup_wrapper");
require("./utils/normalize_options");

// Load up extra types;
require("./convenient_hunk");
require("./convenient_patch");
require("./status_file");
require("./enums.js");

// Import extensions
{% each %}
{% if type != "enum" %}
importExtension("{{ filename }}");
{% endif %}
{% endeach %}
/* jshint ignore:start */
{% each . as idef %}
{% if idef.type != "enum" %}
{% each idef.functions as fn %}
{% if fn.useAsOnRootProto %}

// Inherit directly from the original {{idef.jsClassName}} object.
_{{ idef.jsClassName }}.{{ fn.jsFunctionName }}.__proto__ =
_{{ idef.jsClassName }};

//must go last!
require("./enums");
// Ensure we're using the correct prototype.
_{{ idef.jsClassName }}.{{ fn.jsFunctionName }}.prototype =
_{{ idef.jsClassName }}.prototype;

// Assign the function as the root
rawApi.{{idef.jsClassName}} =
_{{ idef.jsClassName }}.{{ fn.jsFunctionName }};

{% endif %}
{% endeach %}
{% endif %}
{% endeach %}
/* jshint ignore:end */

// Wrap asynchronous methods to return promises.
promisify(exports);
Expand Down
5 changes: 0 additions & 5 deletions lib/attr.js

This file was deleted.

8 changes: 3 additions & 5 deletions lib/blob.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var NodeGit = require("../");
var TreeEntry = require("./tree_entry");
var LookupWrapper = require("./util/lookupWrapper");

var Blob = NodeGit.Blob;
var LookupWrapper = NodeGit.Utils.lookupWrapper;
var TreeEntry = NodeGit.TreeEntry;


/**
* Retrieves the blob pointed to by the oid
Expand Down Expand Up @@ -41,5 +41,3 @@ Blob.prototype.filemode = function() {

return this.isBinary() ? FileMode.EXECUTABLE : FileMode.BLOB;
};

module.exports = Blob;
5 changes: 0 additions & 5 deletions lib/branch.js

This file was deleted.

4 changes: 1 addition & 3 deletions lib/checkout.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var NodeGit = require("../");
var normalizeOptions = require("./util/normalize_options");
var normalizeOptions = NodeGit.Utils.normalizeOptions;

var Checkout = NodeGit.Checkout;
var head = Checkout.head;
Expand Down Expand Up @@ -33,5 +33,3 @@ Checkout.tree = function(repo, treeish, options) {

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

module.exports = Checkout;
10 changes: 1 addition & 9 deletions lib/clone.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var NodeGit = require("../");
var normalizeOptions = require("./util/normalize_options");
var normalizeOptions = NodeGit.Utils.normalizeOptions;

var Clone = NodeGit.Clone;
var clone = Clone.clone;
Expand Down Expand Up @@ -44,11 +44,3 @@ Clone.clone = function(url, local_path, options) {
.then(freeRepository)
.then(openRepository);
};

// Inherit directly from the original clone object.
Clone.clone.__proto__ = Clone;

// Ensure we're using the correct prototype.
Clone.clone.prototype = Clone.prototype;

module.exports = Clone.clone;
5 changes: 1 addition & 4 deletions lib/commit.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
var events = require("events");
var Promise = require("nodegit-promise");
var NodeGit = require("../");
var LookupWrapper = require("./util/lookupWrapper");

var Commit = NodeGit.Commit;
var LookupWrapper = NodeGit.Utils.lookupWrapper;

/**
* Retrieves the commit pointed to by the oid
Expand Down Expand Up @@ -207,5 +206,3 @@ Commit.prototype.getDiff = function(callback) {
Commit.prototype.toString = function() {
return this.sha();
};

module.exports = Commit;
4 changes: 3 additions & 1 deletion lib/convenient_hunk.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var NodeGit = require("../");

function ConvenientHunk(raw, i) {
this.raw = raw;
this.i = i;
Expand Down Expand Up @@ -32,4 +34,4 @@ ConvenientHunk.prototype.lines = function() {
return result;
};

module.exports = ConvenientHunk;
NodeGit.ConvenientHunk = ConvenientHunk;
9 changes: 4 additions & 5 deletions lib/convenient_patch.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
var git = require("../");
var Diff = git.Diff;
var ConvenientHunk = require("./convenient_hunk");
var NodeGit = require("../");
var Diff = NodeGit.Diff;
var ConvenientHunk = NodeGit.ConvenientHunk;

function ConvenientPatch(delta, patch) {
this.delta = delta;
this.patch = patch;
}


/**
* Old name of the file
* @return {String}
Expand Down Expand Up @@ -126,4 +125,4 @@ ConvenientPatch.prototype.isTypeChange = function() {
return this.status() == Diff.DELTA.TYPECHANGE;
};

module.exports = ConvenientPatch;
NodeGit.ConvenientPatch = ConvenientPatch;
10 changes: 4 additions & 6 deletions lib/diff.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var NodeGit = require("../");
var Patch = require("./patch");
var ConvenientPatch = require("./convenient_patch");
var normalizeOptions = require("./util/normalize_options");

var Diff = NodeGit.Diff;
var ConvenientPatch = NodeGit.ConvenientPatch;
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var Patch = NodeGit.Patch;


/**
* Retrieve patches in this difflist
Expand Down Expand Up @@ -62,5 +62,3 @@ Diff.prototype.findSimilar = function(opts) {
opts = normalizeOptions(opts, NodeGit.DiffFindOptions);
return findSimilar.call(this, opts);
};

module.exports = Diff;
2 changes: 0 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,3 @@ var updateAll = Index.prototype.updateAll;
Index.prototype.updateAll = function(pathspec, matchedCallback) {
return updateAll.call(this, pathspec || "*", matchedCallback, null);
};

module.exports = Index;
4 changes: 1 addition & 3 deletions lib/merge.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var NodeGit = require("../");
var normalizeOptions = require("./util/normalize_options");
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var Promise = require("nodegit-promise");

var Merge = NodeGit.Merge;
Expand All @@ -24,5 +24,3 @@ Merge.commits = function(repo, ourCommit, theirCommit, options) {
return mergeCommits.call(this, repo, commits[0], commits[1], options);
});
};

module.exports = Merge;
2 changes: 0 additions & 2 deletions lib/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,3 @@ Obj.prototype.isBlob = function() {
Obj.prototype.isTag = function() {
return this.type() == Obj.TYPE.TAG;
};

module.exports = Obj;
6 changes: 2 additions & 4 deletions lib/odb.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var git = require("../");
var NodeGit = require("../");

var Odb = git.Odb;
var Odb = NodeGit.Odb;
var read = Odb.prototype.read;

Odb.prototype.read = function(oid, callback) {
Expand All @@ -12,5 +12,3 @@ Odb.prototype.read = function(oid, callback) {
return odbObject;
}, callback);
};

module.exports = Odb;
2 changes: 0 additions & 2 deletions lib/odb_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ OdbObject.prototype.toString = function(size) {

return this.data().toBuffer(size).toString();
};

module.exports = OdbObject;
2 changes: 0 additions & 2 deletions lib/oid.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ Object.defineProperties(Oid.prototype, {
Oid.prototype.inspect = function() {
return "[Oid " + this.allocfmt() + "]";
};

module.exports = Oid;
5 changes: 0 additions & 5 deletions lib/patch.js

This file was deleted.

4 changes: 1 addition & 3 deletions lib/reference.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var NodeGit = require("../");
var LookupWrapper = require("./util/lookupWrapper");
var LookupWrapper = NodeGit.Utils.lookupWrapper;

var Reference = NodeGit.Reference;
var Branch = NodeGit.Branch;
Expand Down Expand Up @@ -63,5 +63,3 @@ Reference.prototype.toString = function() {
Reference.prototype.isHead = function() {
return Branch.isHead(this);
};

module.exports = Reference;
4 changes: 2 additions & 2 deletions lib/remote.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var NodeGit = require("../");
var normalizeOptions = require("./util/normalize_options");
var lookupWrapper = require("./util/lookupWrapper");
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var lookupWrapper = NodeGit.Utils.lookupWrapper;

var Remote = NodeGit.Remote;
var setCallbacks = Remote.prototype.setCallbacks;
Expand Down
27 changes: 13 additions & 14 deletions lib/repository.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
var NodeGit = require("../");
var Blob = require("./blob");
var Tree = require("./tree");
var Tag = require("./tag");
var Reference = require("./reference");
var Revwalk = require("./revwalk");
var Commit = require("./commit");
var Remote = require("./remote");
var Promise = require("nodegit-promise");
var normalizeOptions = require("./util/normalize_options");
var Status = require("./status");
var StatusFile = require("./status_file");
var StatusList = require("./status_list");

var TreeBuilder = NodeGit.Treebuilder;
var NodeGit = require("../");
var Blob = NodeGit.Blob;
var Commit = NodeGit.Commit;
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var Reference = NodeGit.Reference;
var Remote = NodeGit.Remote;
var Repository = NodeGit.Repository;
var Revwalk = NodeGit.Revwalk;
var Status = NodeGit.Status;
var StatusFile = NodeGit.StatusFile;
var StatusList = NodeGit.StatusList;
var Tag = NodeGit.Tag;
var Tree = NodeGit.Tree;
var TreeBuilder = NodeGit.Treebuilder;

Object.defineProperty(Repository.prototype, "openIndex", {
enumerable: false,
Expand Down
22 changes: 5 additions & 17 deletions lib/reset.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
var NodeGit = require("../");
var normalizeOptions = require("./util/normalize_options");
var normalizeOptions = NodeGit.Utils.normalizeOptions;

var Reset = NodeGit.Reset;

var defaultFn = Reset.default;

Reset.default = function(repo, target, pathspecs) {
return defaultFn.call(this, repo, target, pathspecs);
};

var reset = Reset.reset;
Reset.reset = function( repo,
target,
resetType,
checkoutOpts,
signature,
logMessage) {
checkoutOpts = normalizeOptions(checkoutOpts, NodeGit.CheckoutOptions);
Reset.reset = function(repo, target, resetType, opts, signature, logMessage) {
opts = normalizeOptions(opts, NodeGit.CheckoutOptions);

return reset.call(
this,
repo,
target,
resetType,
checkoutOpts,
signature,
logMessage);
return reset.call(this, repo, target, resetType, opts, signature, logMessage);
};

module.exports = Reset;
2 changes: 0 additions & 2 deletions lib/revwalk.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,3 @@ Revwalk.prototype.getCommits = function(count) {
return Promise.all(promises);
});
};

module.exports = Revwalk;
2 changes: 0 additions & 2 deletions lib/signature.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ var Signature = NodeGit.Signature;
Signature.prototype.toString = function() {
return this.name().toString() + " <" + this.email().toString() + ">";
};

module.exports = Signature;
4 changes: 1 addition & 3 deletions lib/status.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var NodeGit = require("../");
var normalizeOptions = require("./util/normalize_options");
var normalizeOptions = NodeGit.Utils.normalizeOptions;

var Status = NodeGit.Status;

Expand All @@ -15,5 +15,3 @@ Status.foreachExt = function(repo, opts, callback) {
opts = normalizeOptions(opts, NodeGit.StatusOptions);
return foreachExt(repo, opts, callback, null);
};

module.exports = Status;
3 changes: 1 addition & 2 deletions lib/status_file.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var NodeGit = require("../");

var Status = NodeGit.Status;

var StatusFile = function(args) {
Expand Down Expand Up @@ -87,4 +86,4 @@ var StatusFile = function(args) {
};
};

module.exports = StatusFile;
NodeGit.StatusFile = StatusFile;
Loading