File tree Expand file tree Collapse file tree 1 file changed +73
-0
lines changed Expand file tree Collapse file tree 1 file changed +73
-0
lines changed Original file line number Diff line number Diff line change
1
+ // #include "stdint.h"
2
+
3
+ #flag darwin -I/opt/homebrew/include
4
+ #flag darwin -L/opt/homebrew/lib
5
+
6
+ #flag darwin -lgit2
7
+
8
+ #include "git2/types.h"
9
+ #include "git2/common.h"
10
+ #include "git2/global.h"
11
+ #include "git2/repository.h"
12
+
13
+ #include "git2.h"
14
+
15
+ fn C.git_libgit2_init ()
16
+ fn C.git_libgit2_shutdown ()
17
+ fn C.git_repository_init (repo voidptr , path & char, is_bare bool ) int
18
+
19
+ fn C.git_libgit2_features ()
20
+ fn C.git_commit_lookup (voidptr , voidptr , & C.git_oid) int
21
+
22
+ struct C.git_repository {}
23
+
24
+ struct C.git_commit {}
25
+
26
+ struct C.git_oid {}
27
+
28
+ fn C.git_commit_message (voidptr ) & char
29
+
30
+ fn init () {
31
+ C.git_libgit2_init ()
32
+ }
33
+
34
+ fn shutdown () {
35
+ C.git_libgit2_shutdown ()
36
+ }
37
+
38
+ struct Repo {
39
+ obj & C.git_repository
40
+
41
+ path string
42
+ }
43
+
44
+ fn (r Repo) str () string {
45
+ return 'Repo{ path:${r.path} }'
46
+ }
47
+
48
+ fn (r Repo) log () {
49
+ oid := C.git_oid{}
50
+ commit := & C.git_commit (unsafe { nil })
51
+ ret := C.git_commit_lookup (& commit, r.obj, & oid)
52
+ println (ret)
53
+ s := C.git_commit_message (commit)
54
+ q := cstring_to_vstring (s)
55
+ println (q)
56
+ }
57
+
58
+ fn new_repo (path string ) Repo {
59
+ x := & C.git_repository (unsafe { nil })
60
+ ret := C.git_repository_init (& x, path.str, false )
61
+ println ('ff ${ret} ' )
62
+ return Repo{
63
+ obj: x
64
+ path: path
65
+ }
66
+ }
67
+
68
+ fn main () {
69
+ r := new_repo ('/tmp/v' )
70
+ r.log ()
71
+ C.git_libgit2_features ()
72
+ println (r)
73
+ }
You can’t perform that action at this time.
0 commit comments