forked from gimlet-io/go-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag_cshared.go
187 lines (170 loc) · 3.92 KB
/
tag_cshared.go
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// +build ignore
package main
import (
"C"
"io"
"gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/core"
)
func c_Tag_get_Hash(t uint64) *C.char {
obj, ok := GetObject(Handle(t))
if !ok {
return nil
}
tag := obj.(*git.Tag)
return CBytes(tag.Hash[:])
}
func c_Tag_get_Name(t uint64) *C.char {
obj, ok := GetObject(Handle(t))
if !ok {
return nil
}
tag := obj.(*git.Tag)
return C.CString(tag.Name)
}
func c_Tag_get_Tagger(t uint64) uint64 {
obj, ok := GetObject(Handle(t))
if !ok {
return IH
}
tag := obj.(*git.Tag)
return uint64(RegisterObject(&tag.Tagger))
}
func c_Tag_get_Message(t uint64) *C.char {
obj, ok := GetObject(Handle(t))
if !ok {
return nil
}
tag := obj.(*git.Tag)
return C.CString(tag.Message)
}
func c_Tag_get_TargetType(t uint64) int8 {
obj, ok := GetObject(Handle(t))
if !ok {
return -1
}
tag := obj.(*git.Tag)
return int8(tag.TargetType)
}
func c_Tag_get_Target(t uint64) *C.char {
obj, ok := GetObject(Handle(t))
if !ok {
return nil
}
tag := obj.(*git.Tag)
return CBytes(tag.Target[:])
}
//export c_Tag_Type
func c_Tag_Type(t uint64) int8 {
obj, ok := GetObject(Handle(t))
if !ok {
return -1
}
tag := obj.(*git.Tag)
return int8(tag.Type())
}
//export c_Tag_Decode
func c_Tag_Decode(o uint64) (uint64, int, *C.char) {
obj, ok := GetObject(Handle(o))
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
cobj := obj.(*core.Object)
tag := git.Tag{}
err := tag.Decode(*cobj)
if err != nil {
return IH, ErrorCodeInternal, C.CString(err.Error())
}
return uint64(RegisterObject(&tag)), ErrorCodeSuccess, nil
}
//export c_Tag_Commit
func c_Tag_Commit(t uint64) (uint64, int, *C.char) {
obj, ok := GetObject(Handle(t))
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
tag := obj.(*git.Tag)
commit, err := tag.Commit()
if err != nil {
return IH, ErrorCodeInternal, C.CString(err.Error())
}
return uint64(RegisterObject(commit)), ErrorCodeSuccess, nil
}
//export c_Tag_Tree
func c_Tag_Tree(t uint64) (uint64, int, *C.char) {
obj, ok := GetObject(Handle(t))
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
tag := obj.(*git.Tag)
tree, err := tag.Tree()
if err != nil {
return IH, ErrorCodeInternal, C.CString(err.Error())
}
return uint64(RegisterObject(tree)), ErrorCodeSuccess, nil
}
//export c_Tag_Blob
func c_Tag_Blob(t uint64) (uint64, int, *C.char) {
obj, ok := GetObject(Handle(t))
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
tag := obj.(*git.Tag)
blob, err := tag.Blob()
if err != nil {
return IH, ErrorCodeInternal, C.CString(err.Error())
}
return uint64(RegisterObject(blob)), ErrorCodeSuccess, nil
}
//export c_Tag_Object
func c_Tag_Object(t uint64) (uint64, int, *C.char) {
obj, ok := GetObject(Handle(t))
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
tag := obj.(*git.Tag)
object, err := tag.Object()
if err != nil {
return IH, ErrorCodeInternal, C.CString(err.Error())
}
return uint64(RegisterObject(&object)), ErrorCodeSuccess, nil
}
//export c_Tag_String
func c_Tag_String(t uint64) *C.char {
obj, ok := GetObject(Handle(t))
if !ok {
return nil
}
tag := obj.(*git.Tag)
return C.CString(tag.String())
}
//export c_NewTagIter
func c_NewTagIter(r uint64, i uint64) uint64 {
obj, ok := GetObject(Handle(r))
if !ok {
return IH
}
repo := obj.(*git.Repository)
obj, ok = GetObject(Handle(i))
if !ok {
return IH
}
iter := obj.(*core.ObjectIter)
return uint64(RegisterObject(git.NewTagIter(repo, *iter)))
}
//export c_TagIter_Next
func c_TagIter_Next(i uint64) (uint64, int, *C.char) {
obj, ok := GetObject(Handle(i))
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
tagiter := obj.(*git.TagIter)
tag, err := tagiter.Next()
if err != nil {
if err == io.EOF {
return IH, ErrorCodeSuccess, nil
}
return IH, ErrorCodeInternal, C.CString(err.Error())
}
return uint64(RegisterObject(tag)), ErrorCodeSuccess, nil
}