Skip to content

Commit 8c83ea5

Browse files
committed
Put factory methods as instance methods on repo
1 parent 6527aac commit 8c83ea5

32 files changed

+3265
-2398
lines changed

binding.gyp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
'src/diff_range.cc',
2727
'src/threads.cc',
2828
'src/wrapper.cc',
29+
'src/refdb.cc',
30+
'src/submodule.cc'
2931
],
3032

3133
'include_dirs': [

example/raw-blob.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ repo.open( path.resolve( '../.git' ), function() {
66
var oid = new git.Oid();
77
oid.mkstr( '59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5' );
88

9-
var commit = new git.Commit();
10-
commit.lookup( repo, oid, function( err ) {
9+
repo.getCommit(oid, function( err ) {
1110
var tree = new git.Tree( repo ),
1211
entry = new git.TreeEntry(),
1312
blob = new git.Blob( repo );

include/blob.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,6 @@ class GitBlob : public ObjectWrap {
3131
static Handle<Value> New(const Arguments& args);
3232

3333

34-
static Handle<Value> Lookup(const Arguments& args);
35-
static void LookupWork(uv_work_t* req);
36-
static void LookupAfterWork(uv_work_t* req);
37-
38-
struct LookupBaton {
39-
uv_work_t request;
40-
int error_code;
41-
const git_error* error;
42-
git_blob * blob;
43-
Persistent<Value> repoReference;
44-
git_repository * repo;
45-
Persistent<Value> idReference;
46-
const git_oid * id;
47-
Persistent<Function> callback;
48-
};
4934
static Handle<Value> Oid(const Arguments& args);
5035
static Handle<Value> Content(const Arguments& args);
5136
static Handle<Value> Size(const Arguments& args);

include/commit.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,6 @@ class GitCommit : public ObjectWrap {
3131
static Handle<Value> New(const Arguments& args);
3232

3333

34-
static Handle<Value> Lookup(const Arguments& args);
35-
static void LookupWork(uv_work_t* req);
36-
static void LookupAfterWork(uv_work_t* req);
37-
38-
struct LookupBaton {
39-
uv_work_t request;
40-
int error_code;
41-
const git_error* error;
42-
git_commit * commit;
43-
Persistent<Value> repoReference;
44-
git_repository * repo;
45-
Persistent<Value> idReference;
46-
const git_oid * id;
47-
Persistent<Function> callback;
48-
};
4934
static Handle<Value> Oid(const Arguments& args);
5035
static Handle<Value> MessageEncoding(const Arguments& args);
5136
static Handle<Value> Message(const Arguments& args);

include/object.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,6 @@ class GitObject : public ObjectWrap {
3131
static Handle<Value> New(const Arguments& args);
3232

3333

34-
static Handle<Value> Lookup(const Arguments& args);
35-
static void LookupWork(uv_work_t* req);
36-
static void LookupAfterWork(uv_work_t* req);
37-
38-
struct LookupBaton {
39-
uv_work_t request;
40-
int error_code;
41-
const git_error* error;
42-
git_object * object;
43-
Persistent<Value> repoReference;
44-
git_repository * repo;
45-
Persistent<Value> idReference;
46-
const git_oid * id;
47-
Persistent<Value> typeReference;
48-
git_otype type;
49-
Persistent<Function> callback;
50-
};
5134
static Handle<Value> Oid(const Arguments& args);
5235
static Handle<Value> Type(const Arguments& args);
5336
static Handle<Value> Owner(const Arguments& args);

include/refdb.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* This code is auto-generated; unless you know what you're doing, do not modify!
3+
**/
4+
5+
#ifndef GITREFDB_H
6+
#define GITREFDB_H
7+
8+
#include <v8.h>
9+
#include <node.h>
10+
#include <string>
11+
12+
#include "git2.h"
13+
14+
using namespace node;
15+
using namespace v8;
16+
17+
class GitRefDb : public ObjectWrap {
18+
public:
19+
20+
static Persistent<Function> constructor_template;
21+
static void Initialize (Handle<v8::Object> target);
22+
23+
git_refdb *GetValue();
24+
25+
static Handle<Value> New(void *raw);
26+
27+
private:
28+
GitRefDb(git_refdb *raw);
29+
~GitRefDb();
30+
31+
static Handle<Value> New(const Arguments& args);
32+
33+
34+
git_refdb *raw;
35+
};
36+
37+
#endif

include/reference.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,6 @@ class GitReference : public ObjectWrap {
3131
static Handle<Value> New(const Arguments& args);
3232

3333

34-
static Handle<Value> Lookup(const Arguments& args);
35-
static void LookupWork(uv_work_t* req);
36-
static void LookupAfterWork(uv_work_t* req);
37-
38-
struct LookupBaton {
39-
uv_work_t request;
40-
int error_code;
41-
const git_error* error;
42-
git_reference * out;
43-
Persistent<Value> repoReference;
44-
git_repository * repo;
45-
Persistent<Value> nameReference;
46-
const char * name;
47-
Persistent<Function> callback;
48-
};
4934
static Handle<Value> OidForName(const Arguments& args);
5035
static void OidForNameWork(uv_work_t* req);
5136
static void OidForNameAfterWork(uv_work_t* req);
@@ -61,8 +46,6 @@ class GitReference : public ObjectWrap {
6146
const char * name;
6247
Persistent<Function> callback;
6348
};
64-
static Handle<Value> CreateSymbolic(const Arguments& args);
65-
static Handle<Value> Create(const Arguments& args);
6649
static Handle<Value> Oid(const Arguments& args);
6750
static Handle<Value> Name(const Arguments& args);
6851
static Handle<Value> Type(const Arguments& args);

include/remote.h

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* This code is auto-generated; unless you know what you're doing, do not modify!
33
**/
44

5-
#ifndef REMOTE_H
6-
#define REMOTE_H
5+
#ifndef GITREMOTE_H
6+
#define GITREMOTE_H
77

88
#include <v8.h>
99
#include <node.h>
@@ -14,7 +14,7 @@
1414
using namespace node;
1515
using namespace v8;
1616

17-
class Remote : public ObjectWrap {
17+
class GitRemote : public ObjectWrap {
1818
public:
1919

2020
static Persistent<Function> constructor_template;
@@ -25,31 +25,12 @@ class Remote : public ObjectWrap {
2525
static Handle<Value> New(void *raw);
2626

2727
private:
28-
Remote(git_remote *raw);
29-
~Remote();
28+
GitRemote(git_remote *raw);
29+
~GitRemote();
3030

3131
static Handle<Value> New(const Arguments& args);
3232

3333

34-
static Handle<Value> Create(const Arguments& args);
35-
static void CreateWork(uv_work_t* req);
36-
static void CreateAfterWork(uv_work_t* req);
37-
38-
struct CreateBaton {
39-
uv_work_t request;
40-
int error_code;
41-
const git_error* error;
42-
git_remote * out;
43-
Persistent<Value> repoReference;
44-
git_repository * repo;
45-
Persistent<Value> nameReference;
46-
const char * name;
47-
Persistent<Value> urlReference;
48-
const char * url;
49-
Persistent<Function> callback;
50-
};
51-
static Handle<Value> CreateInmemory(const Arguments& args);
52-
static Handle<Value> Load(const Arguments& args);
5334
static Handle<Value> Save(const Arguments& args);
5435
static Handle<Value> Name(const Arguments& args);
5536
static Handle<Value> Url(const Arguments& args);

include/repo.h

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,157 @@ class GitRepo : public ObjectWrap {
6161
};
6262
static Handle<Value> Path(const Arguments& args);
6363
static Handle<Value> Workdir(const Arguments& args);
64+
static Handle<Value> GetBlob(const Arguments& args);
65+
static void GetBlobWork(uv_work_t* req);
66+
static void GetBlobAfterWork(uv_work_t* req);
67+
68+
struct GetBlobBaton {
69+
uv_work_t request;
70+
int error_code;
71+
const git_error* error;
72+
git_blob * blob;
73+
Persistent<Value> repoReference;
74+
git_repository * repo;
75+
Persistent<Value> idReference;
76+
const git_oid * id;
77+
Persistent<Function> callback;
78+
};
79+
static Handle<Value> GetCommit(const Arguments& args);
80+
static void GetCommitWork(uv_work_t* req);
81+
static void GetCommitAfterWork(uv_work_t* req);
82+
83+
struct GetCommitBaton {
84+
uv_work_t request;
85+
int error_code;
86+
const git_error* error;
87+
git_commit * commit;
88+
Persistent<Value> repoReference;
89+
git_repository * repo;
90+
Persistent<Value> idReference;
91+
const git_oid * id;
92+
Persistent<Function> callback;
93+
};
94+
static Handle<Value> GetObject(const Arguments& args);
95+
static void GetObjectWork(uv_work_t* req);
96+
static void GetObjectAfterWork(uv_work_t* req);
97+
98+
struct GetObjectBaton {
99+
uv_work_t request;
100+
int error_code;
101+
const git_error* error;
102+
git_object * object;
103+
Persistent<Value> repoReference;
104+
git_repository * repo;
105+
Persistent<Value> idReference;
106+
const git_oid * id;
107+
Persistent<Value> typeReference;
108+
git_otype type;
109+
Persistent<Function> callback;
110+
};
111+
static Handle<Value> GetReference(const Arguments& args);
112+
static void GetReferenceWork(uv_work_t* req);
113+
static void GetReferenceAfterWork(uv_work_t* req);
114+
115+
struct GetReferenceBaton {
116+
uv_work_t request;
117+
int error_code;
118+
const git_error* error;
119+
git_reference * out;
120+
Persistent<Value> repoReference;
121+
git_repository * repo;
122+
Persistent<Value> nameReference;
123+
const char * name;
124+
Persistent<Function> callback;
125+
};
126+
static Handle<Value> CreateSymbolicReference(const Arguments& args);
127+
static Handle<Value> CreateReference(const Arguments& args);
128+
static Handle<Value> CreateRevWalk(const Arguments& args);
129+
static Handle<Value> GetSubmodule(const Arguments& args);
130+
static Handle<Value> AddSubmodule(const Arguments& args);
131+
static Handle<Value> GetTag(const Arguments& args);
132+
static void GetTagWork(uv_work_t* req);
133+
static void GetTagAfterWork(uv_work_t* req);
134+
135+
struct GetTagBaton {
136+
uv_work_t request;
137+
int error_code;
138+
const git_error* error;
139+
git_tag * out;
140+
Persistent<Value> repoReference;
141+
git_repository * repo;
142+
Persistent<Value> idReference;
143+
const git_oid * id;
144+
Persistent<Function> callback;
145+
};
146+
static Handle<Value> CreateTag(const Arguments& args);
147+
static void CreateTagWork(uv_work_t* req);
148+
static void CreateTagAfterWork(uv_work_t* req);
149+
150+
struct CreateTagBaton {
151+
uv_work_t request;
152+
int error_code;
153+
const git_error* error;
154+
git_oid * oid;
155+
Persistent<Value> repoReference;
156+
git_repository * repo;
157+
Persistent<Value> tag_nameReference;
158+
const char * tag_name;
159+
Persistent<Value> targetReference;
160+
const git_object * target;
161+
Persistent<Value> taggerReference;
162+
const git_signature * tagger;
163+
Persistent<Value> messageReference;
164+
const char * message;
165+
Persistent<Value> forceReference;
166+
int force;
167+
Persistent<Function> callback;
168+
};
169+
static Handle<Value> CreateLightweightTag(const Arguments& args);
170+
static void CreateLightweightTagWork(uv_work_t* req);
171+
static void CreateLightweightTagAfterWork(uv_work_t* req);
172+
173+
struct CreateLightweightTagBaton {
174+
uv_work_t request;
175+
int error_code;
176+
const git_error* error;
177+
git_oid * oid;
178+
Persistent<Value> repoReference;
179+
git_repository * repo;
180+
Persistent<Value> tag_nameReference;
181+
const char * tag_name;
182+
Persistent<Value> targetReference;
183+
const git_object * target;
184+
Persistent<Value> forceReference;
185+
int force;
186+
Persistent<Function> callback;
187+
};
188+
static Handle<Value> GetTree(const Arguments& args);
189+
static void GetTreeWork(uv_work_t* req);
190+
static void GetTreeAfterWork(uv_work_t* req);
191+
192+
struct GetTreeBaton {
193+
uv_work_t request;
194+
int error_code;
195+
const git_error* error;
196+
git_tree * out;
197+
Persistent<Value> repoReference;
198+
git_repository * repo;
199+
Persistent<Value> idReference;
200+
const git_oid * id;
201+
Persistent<Function> callback;
202+
};
203+
static Handle<Value> ReloadSubmodules(const Arguments& args);
204+
static void ReloadSubmodulesWork(uv_work_t* req);
205+
static void ReloadSubmodulesAfterWork(uv_work_t* req);
206+
207+
struct ReloadSubmodulesBaton {
208+
uv_work_t request;
209+
int error_code;
210+
const git_error* error;
211+
Persistent<Value> repoReference;
212+
git_repository * repo;
213+
Persistent<Function> callback;
214+
};
64215
git_repository *raw;
65216
};
66217

include/revwalk.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class GitRevWalk : public ObjectWrap {
3131
static Handle<Value> New(const Arguments& args);
3232

3333

34-
static Handle<Value> Make(const Arguments& args);
3534
static Handle<Value> Reset(const Arguments& args);
3635
static Handle<Value> Push(const Arguments& args);
3736
static void PushWork(uv_work_t* req);

0 commit comments

Comments
 (0)