From 95f695136203a372751c19b6353aeb5ae32ea40e Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Sat, 19 Jul 2014 00:28:14 -0400 Subject: [PATCH] Added new methods in checkout and repository --- generate/descriptor.json | 63 +++++++++++++++++++- generate/setup.js | 6 ++ generate/types.json | 123 ++++++++++++++++++++++++++++++++------- lib/checkout.js | 5 ++ lib/nodegit.js | 29 +++++---- test/tests/checkout.js | 15 +++++ 6 files changed, 206 insertions(+), 35 deletions(-) create mode 100644 lib/checkout.js create mode 100644 test/tests/checkout.js diff --git a/generate/descriptor.json b/generate/descriptor.json index 6fedbb9e8..53203882d 100644 --- a/generate/descriptor.json +++ b/generate/descriptor.json @@ -92,7 +92,40 @@ }, "checkout": { - "cType": null + "cType": null, + + "dependencies": [ + "../include/functions/copy.h", + "../include/checkout.h", + "../include/checkout_options.h", + "../include/repository.h", + "../include/index.h", + "../include/object.h" + ], + + "functions": { + "git_checkout_head": { + "ignore": false + }, + + "git_checkout_index": { + "ignore": false + }, + + "git_checkout_tree": { + "ignore": false + }, + + "git_checkout_init_options": { + "ignore": false + } + } + }, + + "checkout_options": { + "isStruct": true, + "cType": "git_checkout_options", + "fields": [] }, "clone": { @@ -595,6 +628,18 @@ }, "repository": { + "dependencies": [ + "../include/functions/copy.h", + "../include/repository.h", + "../include/repository.h", + "../include/odb.h", + "../include/config.h", + "../include/refdb.h", + "../include/index.h", + "../include/oid.h", + "../include/repository_init_options.h" + ], + "functions": { "git_repository_open": { "isConstructorMethod": true, @@ -608,10 +653,26 @@ "git_repository_init": { "isConstructorMethod": true, "ignore": false + }, + + "git_repository_init_ext": { + "isConstructorMethod": true, + "ignore": false + }, + + "git_repository_init_init_options": { + "ignore": false, + "isConstructorMethod": true } } }, + "repository_init_options": { + "isStruct": true, + "cType": "git_repository_init_options", + "fields": [] + }, + "reset": { "cType": null }, diff --git a/generate/setup.js b/generate/setup.js index 7389da288..970895ee4 100644 --- a/generate/setup.js +++ b/generate/setup.js @@ -42,6 +42,12 @@ typeMap.__proto__ = { "git_filter_check_fn": { cpp: "Function", js: "Function" }, "git_filter_apply_fn": { cpp: "Function", js: "Function" }, "git_filter_cleanup_fn": { cpp: "Function", js: "Function" }, + "const git_checkout_options *": { cpp: "GitCheckoutOptions", js: "CheckoutOptions" }, + "git_checkout_notify_cb": { cpp: "Function", js: "Function" }, + "git_checkout_progress_cb": { cpp: "Function", js: "Function" }, + "git_cherry_pick_options *": { cpp: "GitCherryPickOptions", js: "CherryPickOptions" }, + "const git_cherry_pick_options *": { cpp: "GitCherryPickOptions", js: "CherryPickOptions" }, + "const git_merge_options *": { cpp: "GitMergeOptions", js: "MergeOptions" } }; var files = []; diff --git a/generate/types.json b/generate/types.json index 347cae0b9..a664a78d4 100644 --- a/generate/types.json +++ b/generate/types.json @@ -168,24 +168,24 @@ "js": "branchRemoteName" }, "git_checkout_head": { - "cpp": "CheckoutHead", - "js": "checkoutHead" + "cpp": "Head", + "js": "head" }, "git_checkout_opts *": { "js": "CheckoutOpts", "cpp": "CheckoutOpts" }, "git_checkout_index": { - "cpp": "CheckoutIndex", - "js": "checkoutIndex" + "cpp": "Index", + "js": "index" }, "git_index *": { "cpp": "GitIndex", "js": "Index" }, "git_checkout_tree": { - "cpp": "CheckoutTree", - "js": "checkoutTree" + "cpp": "Tree", + "js": "tree" }, "const git_object *": { "cpp": "GitObject", @@ -1733,8 +1733,8 @@ "js": "initExt" }, "git_repository_init_options *": { - "js": "RepositoryInitOptions", - "cpp": "RepositoryInitOptions" + "cpp": "GitRepositoryInitOptions", + "js": "RepositoryInitOptions" }, "git_repository_head": { "cpp": "Head", @@ -3081,28 +3081,28 @@ "js": "Checkout" }, "git_checkout_head *": { - "cpp": "CheckoutHead", - "js": "checkoutHead" + "cpp": "Head", + "js": "head" }, "const git_checkout_head *": { - "cpp": "CheckoutHead", - "js": "checkoutHead" + "cpp": "Head", + "js": "head" }, "git_checkout_index *": { - "cpp": "CheckoutIndex", - "js": "checkoutIndex" + "cpp": "Index", + "js": "index" }, "const git_checkout_index *": { - "cpp": "CheckoutIndex", - "js": "checkoutIndex" + "cpp": "Index", + "js": "index" }, "git_checkout_tree *": { - "cpp": "CheckoutTree", - "js": "checkoutTree" + "cpp": "Tree", + "js": "tree" }, "const git_checkout_tree *": { - "cpp": "CheckoutTree", - "js": "checkoutTree" + "cpp": "Tree", + "js": "tree" }, "git_clone **": { "cpp": "GitClone", @@ -3365,7 +3365,6 @@ "js": "Config" }, "const git_config **": { - "cpp": "GitConfig", "js": "Config" }, "git_config_find_global *": { @@ -9067,5 +9066,85 @@ "const git_remote_delete *": { "cpp": "Delete", "js": "delete" + }, + "git_checkout_options": { + "cpp": "GitCheckoutOptions", + "js": "CheckoutOptions" + }, + "git_checkout_options **": { + "cpp": "GitCheckoutOptions", + "js": "CheckoutOptions" + }, + "git_checkout_options *": { + "cpp": "GitCheckoutOptions", + "js": "CheckoutOptions" + }, + "const git_checkout_options **": { + "cpp": "GitCheckoutOptions", + "js": "CheckoutOptions" + }, + "const git_checkout_options *": { + "cpp": "GitCheckoutOptions", + "js": "CheckoutOptions" + }, + "git_cherry": { + "cpp": "GitCherry", + "js": "Cherry" + }, + "git_cherry **": { + "cpp": "GitCherry", + "js": "Cherry" + }, + "git_cherry *": { + "cpp": "GitCherry", + "js": "Cherry" + }, + "const git_cherry **": { + "cpp": "GitCherry", + "js": "Cherry" + }, + "const git_cherry *": { + "cpp": "GitCherry", + "js": "Cherry" + }, + "git_checkout_init_options": { + "cpp": "InitOptions", + "js": "initOptions" + }, + "git_checkout_init_options *": { + "cpp": "InitOptions", + "js": "initOptions" + }, + "const git_checkout_init_options *": { + "cpp": "InitOptions", + "js": "initOptions" + }, + "git_repository_init_options": { + "cpp": "GitRepositoryInitOptions", + "js": "RepositoryInitOptions" + }, + "git_repository_init_options **": { + "cpp": "GitRepositoryInitOptions", + "js": "RepositoryInitOptions" + }, + "const git_repository_init_options **": { + "cpp": "GitRepositoryInitOptions", + "js": "RepositoryInitOptions" + }, + "const git_repository_init_options *": { + "cpp": "GitRepositoryInitOptions", + "js": "RepositoryInitOptions" + }, + "git_repository_init_init_options": { + "cpp": "InitInitOptions", + "js": "initInitOptions" + }, + "git_repository_init_init_options *": { + "cpp": "InitInitOptions", + "js": "initInitOptions" + }, + "const git_repository_init_init_options *": { + "cpp": "InitInitOptions", + "js": "initInitOptions" } -} \ No newline at end of file +} diff --git a/lib/checkout.js b/lib/checkout.js new file mode 100644 index 000000000..82c02e317 --- /dev/null +++ b/lib/checkout.js @@ -0,0 +1,5 @@ +var NodeGit = require("../"); + +var Checkout = NodeGit.Checkout; + +module.exports = Checkout; diff --git a/lib/nodegit.js b/lib/nodegit.js index e52aa1760..77e4e270e 100644 --- a/lib/nodegit.js +++ b/lib/nodegit.js @@ -39,18 +39,23 @@ descriptors.forEach(function(descriptor) { exports.__proto__ = rawApi; // Import extensions -require("./commit.js"); -require("./diff.js"); -require("./blob.js"); -require("./object.js"); -require("./signature.js"); -require("./odb.js"); -require("./oid.js"); -require("./index.js"); -require("./repository.js"); -require("./refs.js"); -require("./revwalk.js"); -require("./tree.js"); +require("./attr"); +require("./blob"); +require("./checkout"); +require("./commit"); +require("./diff"); +require("./index"); +require("./object"); +require("./odb"); +require("./oid"); +require("./patch"); +require("./refs"); +require("./remote"); +require("./repository"); +require("./revwalk"); +require("./signature"); +require("./tree"); +require("./tree_entry"); // Wrap asynchronous methods to return promises. promisify(exports); diff --git a/test/tests/checkout.js b/test/tests/checkout.js new file mode 100644 index 000000000..327c7d399 --- /dev/null +++ b/test/tests/checkout.js @@ -0,0 +1,15 @@ +var path = require("path"); + +describe("Checkout", function() { + var reposPath = path.resolve("test/repos/workdir/.git"); + + var Repository = require("../../lib/repository"); + + before(function() { + var test = this; + + return Repository.open(reposPath).then(function(repository) { + test.repository = repository; + }); + }); +});