forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
repo.h
executable file
·83 lines (66 loc) · 1.89 KB
/
repo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
Copyright (c) 2011, Tim Branyen @tbranyen <tim@tabdeveloper.com>
*/
#ifndef REPO_H
#define REPO_H
#include <v8.h>
#include <node.h>
#include <node_events.h>
#include <string>
#include "../vendor/libgit2/include/git2.h"
#include "object.h"
using namespace node;
using namespace v8;
class GitRepo : public EventEmitter {
public:
static Persistent<FunctionTemplate> constructor_template;
static void Initialize(Handle<v8::Object> target);
git_repository* GetValue();
void SetValue(git_repository* repo);
// Asynchronous
int Open(const char* path);
int Init(const char* path, bool is_bare);
// Synchronous
void Free();
// TODO: Implement these methods
//int Open2(const char* path);
//int Open3(const char* path);
//int Lookup(Object **obj, Oid *id, Otype type);
//Odb Database();
//int Index(Index **index);
//int NewObject(git_object **obj, Otype type);
protected:
GitRepo() {}
~GitRepo() {}
static Handle<Value> New(const Arguments& args);
static Handle<Value> Open(const Arguments& args);
static void EIO_Open(eio_req* req);
static int EIO_AfterOpen(eio_req* req);
static Handle<Value> Lookup(const Arguments& args);
static int EIO_Lookup(eio_req* req);
static int EIO_AfterLookup(eio_req* req);
static Handle<Value> Free(const Arguments& args);
static Handle<Value> Init(const Arguments& args);
static void EIO_Init(eio_req* req);
static int EIO_AfterInit(eio_req* req);
private:
git_repository* repo;
struct open_request {
GitRepo* repo;
int err;
std::string path;
Persistent<Function> callback;
};
struct lookup_request {
GitRepo* repo;
Persistent<Function> callback;
};
struct init_request {
GitRepo* repo;
int err;
std::string path;
bool is_bare;
Persistent<Function> callback;
};
};
#endif