xs/Tag.xs

filter: Statementstmt 98.1% 52 / 53 Branchbran 88.8% 16 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 95.7% 68 / 71 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/Patch.xs ↑ Summary xs/Odb.xs »
1 MODULE = Git::Raw PACKAGE = Git::Raw::Tag
2  
3 SV *
4 create(class, repo, name, msg, tagger, target)
5 SV *class
6 SV *repo
7 SV *name
8 SV *msg
9 Signature tagger
10 SV *target
11  
12 PREINIT:
13 int rc;
14 Tag tag;
15  
16 git_oid oid;
17 git_object *obj;
18 Repository repo_ptr;
19  
20 CODE:
21 1 obj = git_sv_to_obj(target);
22  
23 1 ▶ if (obj == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (obj == NULL) 0 1 1
24 0 croak_usage("Invalid type for '%s', expected a commitish", "target");
25  
26 1 repo_ptr = GIT_SV_TO_PTR(Repository, repo);
27  
28 1 rc = git_tag_create(
29 &oid, repo_ptr -> repository, git_ensure_pv(name, "name"),
30 obj, tagger, git_ensure_pv(msg, "msg"), 0
31 );
32 1 git_check_error(rc);
33  
34 1 rc = git_tag_lookup(&tag, repo_ptr -> repository, &oid);
35 1 git_check_error(rc);
36  
37 2 GIT_NEW_OBJ_WITH_MAGIC(
38 RETVAL, SvPVbyte_nolen(class), tag, SvRV(repo)
39 );
40  
41 OUTPUT: RETVAL
42  
43 SV *
44 lookup(class, repo, id)
45 SV *class
46 SV *repo
47 SV *id
48  
49 PREINIT:
50 int rc;
51  
52 Tag tag;
53 git_oid oid;
54 Repository repo_ptr;
55  
56 STRLEN len;
57 const char *id_str;
58  
59 CODE:
60 2 id_str = git_ensure_pv_with_len(id, "id", &len);
61  
62 2 rc = git_oid_fromstrn(&oid, id_str, len);
63 2 git_check_error(rc);
64  
65 2 repo_ptr = GIT_SV_TO_PTR(Repository, repo);
66 2 rc = git_tag_lookup_prefix(&tag, repo_ptr -> repository, &oid, len);
67  
68 2 ▶ if (rc == GIT_ENOTFOUND) {
Branch: 1 branch
BranchTrueFalseTotal
if (rc == GIT_ENOTFOUND) { 1 1 2
69 1 RETVAL = &PL_sv_undef;
70 } else {
71 1 git_check_error(rc);
72  
73 2 GIT_NEW_OBJ_WITH_MAGIC(
74 RETVAL, SvPVbyte_nolen(class), tag, SvRV(repo)
75 );
76 }
77  
78 OUTPUT: RETVAL
79  
80 SV *
81 owner(self)
82 SV *self
83  
84 PREINIT:
85 SV *repo;
86  
87 CODE:
88 1 repo = GIT_SV_TO_MAGIC(self);
89 1 RETVAL = newRV_inc(repo);
90  
91 OUTPUT: RETVAL
92  
93 void
94 foreach(class, repo, cb, ...)
95 SV *class
96 SV *repo
97 SV *cb
98  
99 PROTOTYPE: $$$;$
100 PREINIT:
101 int rc;
102  
103 CODE:
104 11 git_foreach_payload payload = {
105 11 GIT_SV_TO_PTR(Repository, repo),
106 repo,
107 cb,
108 1,
109 1
110 };
111  
112 11 ▶ if (items == 4 && SvOK(ST(3))) {
Branch: 2 branches
BranchTrueFalseTotal
if (items == 4 && SvOK(ST(3))) { 6 5 11
if (items == 4 && SvOK(ST(3))) { 5 1 6
113 5 const char *type = git_ensure_pv(ST(3), "type");
114  
115 5 ▶ if (strcmp(type, "lightweight") == 0)
Branch: 1 branch
BranchTrueFalseTotal
if (strcmp(type, "lightweight") == 0) 2 3 5
116 2 payload.annotated = 0;
117 3 ▶ else if (strcmp(type, "annotated") == 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcmp(type, "annotated") == 0) 1 2 3
118 1 payload.lightweight = 0;
119 else {
120 2 ▶ if (strcmp(type, "all") != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (strcmp(type, "all") != 0) 1 1 2
121 1 croak_usage("Invalid value for 'type', expected "
122 "'all', 'lightweight' or 'annotated'");
123 }
124 }
125  
126 10 rc = git_tag_foreach(
127 10 payload.repo_ptr -> repository,
128 git_tag_foreach_cbb,
129 &payload
130 );
131  
132 10 ▶ if (rc != GIT_EUSER)
Branch: 1 branch
BranchTrueFalseTotal
if (rc != GIT_EUSER) 9 1 10
133 9 git_check_error(rc);
134  
135 void
136 delete(self)
137 SV *self
138  
139 PREINIT:
140 int rc;
141  
142 Tag tag_ptr;
143 Repository repo;
144  
145 CODE:
146 1 tag_ptr = GIT_SV_TO_PTR(Tag, self);
147  
148 1 repo = INT2PTR(
149 Repository, SvIV((SV *) GIT_SV_TO_MAGIC(self))
150 );
151  
152 1 rc = git_tag_delete(repo -> repository, git_tag_name(tag_ptr));
153 1 git_check_error(rc);
154  
155 1 git_tag_free(tag_ptr);
156 1 sv_setiv(SvRV(self), 0);
157  
158 SV *
159 id(self)
160 Tag self
161  
162 CODE:
163 4 RETVAL = git_oid_to_sv(git_tag_id(self));
164  
165 OUTPUT: RETVAL
166  
167 SV *
168 name(self)
169 Tag self
170  
171 CODE:
172 2 RETVAL = newSVpv(git_tag_name(self), 0);
173  
174 OUTPUT: RETVAL
175  
176 SV *
177 message(self)
178 Tag self
179  
180 CODE:
181 2 RETVAL = newSVpv(git_tag_message(self), 0);
182  
183 OUTPUT: RETVAL
184  
185 SV *
186 tagger(self)
187 Tag self
188  
189 PREINIT:
190 int rc;
191 Signature tagger, result;
192  
193 CODE:
194 4 RETVAL = &PL_sv_undef;
195  
196 4 ▶ if ((tagger = (Signature) git_tag_tagger(self)) != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if ((tagger = (Signature) git_tag_tagger(self)) != NULL) { 4 0 4
197 4 rc = git_signature_dup(&result, tagger);
198 4 git_check_error(rc);
199  
200 4 GIT_NEW_OBJ(
201 RETVAL, "Git::Raw::Signature", result
202 );
203 }
204  
205 OUTPUT: RETVAL
206  
207 SV *
208 target(self)
209 SV *self
210  
211 PREINIT:
212 int rc;
213 git_object *obj;
214  
215 CODE:
216 1 rc = git_tag_target(&obj, GIT_SV_TO_PTR(Tag, self));
217 1 git_check_error(rc);
218  
219 1 RETVAL = git_obj_to_sv(obj, GIT_SV_TO_MAGIC(self));
220  
221 OUTPUT: RETVAL
222  
223 void
224 DESTROY(self)
225 SV *self
226  
227 CODE:
228 7 git_tag_free(GIT_SV_TO_PTR(Tag, self));
229 7 SvREFCNT_dec(GIT_SV_TO_MAGIC(self));
« xs/Patch.xs ↑ Summary xs/Odb.xs »