Permalink
Browse files

Work on submodule support.

  • Loading branch information...
1 parent 7753518 commit 1605fc03ec006f6c8422e68a7dc43eeb87493259 @samcday samcday committed Jan 11, 2013
Showing with 71 additions and 0 deletions.
  1. +1 −0 binding.gyp
  2. +2 −0 src/gitteh.cc
  3. +1 −0 src/repository.cc
  4. +1 −0 src/repository.h
  5. +53 −0 src/submodule.cc
  6. +13 −0 src/submodule.h
View
@@ -13,6 +13,7 @@
'src/tag.cc',
'src/remote.cc',
'src/index.cc',
+ 'src/submodule.cc'
],
'todosources': [
'src/index_entry.cc',
View
@@ -31,6 +31,7 @@
#include "tag.h"
#include "remote.h"
#include "index.h"
+#include "submodule.h"
namespace gitteh {
@@ -61,6 +62,7 @@ init(Handle<Object> target) {
Blob::Init(target);
Tag::Init(target);
Index::Init(target);
+ Submodule::Init(target);
Remote::Init(target);
View
@@ -244,6 +244,7 @@ void Repository::Init(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "createSymReference", CreateSymReference);
NODE_SET_PROTOTYPE_METHOD(t, "remote", GetRemote);
NODE_SET_PROTOTYPE_METHOD(t, "createRemote", CreateRemote);
+ NODE_SET_PROTOTYPE_METHOD(t, "getSubmodule", GetSubmodule);
NODE_SET_METHOD(target, "openRepository", OpenRepository);
NODE_SET_METHOD(target, "initRepository", InitRepository);
View
@@ -40,6 +40,7 @@ class Repository : public ObjectWrap {
static Handle<Value> GetRemote(const Arguments&);
static Handle<Value> Exists(const Arguments&);
static Handle<Value> CreateRemote(const Arguments&);
+ static Handle<Value> GetSubmodule(const Arguments&);
void close();
View
@@ -0,0 +1,53 @@
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010 Sam Day
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "submodule.h"
+
+static Persistent<String> name_symbol;
+static Persistent<String> path_symbol;
+static Persistent<String> url_symbol;
+static Persistent<String> oid_symbol;
+
+namespace gitteh {
+ namespace Submodule {
+ void Init(Handle<Object> target) {
+ HandleScope scope;
+ name_symbol = NODE_PSYMBOL("name");
+ path_symbol = NODE_PSYMBOL("path");
+ url_symbol = NODE_PSYMBOL("url");
+ oid_symbol = NODE_PSYMBOL("oid");
+ }
+
+ Handle<Object> Create(git_submodule *submodule) {
+ HandleScope scope;
+ Handle<Object> o = Object::New();
+
+ o->Set(name_symbol, CastToJS(submodule->name));
+ o->Set(path_symbol, CastToJS(submodule->path));
+ o->Set(url_symbol, CastToJS(submodule->url));
+ o->Set(oid_symbol, CastToJS(submodule->oid));
+ return scope.Close(o);
+ }
+ }
+};
View
@@ -0,0 +1,13 @@
+#ifndef GITTEH_SUBMODULE_H
+#define GITTEH_SUBMODULE_H
+
+#include "gitteh.h"
+
+namespace gitteh {
+ namespace Submodule {
+ void Init(Handle<Object>);
+ Handle<Object> Create(git_submodule*);
+ }
+};
+
+#endif // GITTEH_SUBMODULE_H

0 comments on commit 1605fc0

Please sign in to comment.