xs/Note.xs

filter: Statementstmt 100% 60 / 60 Branchbran 100% 16 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 100% 76 / 76 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/Mempack.xs ↑ Summary xs/Odb/Backend/OnePack.xs »
1 MODULE = Git::Raw PACKAGE = Git::Raw::Note
2  
3 SV *
4 create(class, repo, commitish, content, ...)
5 const char *class
6 SV *repo
7 SV *commitish
8 SV *content
9  
10 PROTOTYPE: $$$$;$$
11 PREINIT:
12 5 int rc, force = 0;
13  
14 Note note;
15 Repository repo_ptr;
16 Signature sig;
17  
18 git_oid oid;
19  
20 5 const char *ref_name = NULL;
21  
22 CODE:
23 5 ▶ if (items >= 5 && SvOK(ST(4)))
Branch: 2 branches
BranchTrueFalseTotal
if (items >= 5 && SvOK(ST(4))) 3 2 5
if (items >= 5 && SvOK(ST(4))) 2 1 3
24 2 ref_name = git_ensure_pv(ST(4), "refname");
25  
26 5 ▶ if (items >= 6)
Branch: 1 branch
BranchTrueFalseTotal
if (items >= 6) 1 4 5
27 1 force = (int) git_ensure_iv(ST(5), "force");
28  
29 5 repo_ptr = GIT_SV_TO_PTR(Repository, repo);
30  
31 5 rc = git_signature_default(&sig, repo_ptr -> repository);
32 5 git_check_error(rc);
33  
34 10 rc = git_note_create(NULL, repo_ptr -> repository, ref_name, sig, sig,
35 5 git_sv_to_commitish(repo_ptr -> repository, commitish, &oid),
36 git_ensure_pv(content, "content"), force
37 );
38 5 git_signature_free(sig);
39 5 git_check_error(rc);
40  
41 3 rc = git_note_read(
42 &note, repo_ptr -> repository, ref_name, &oid
43 );
44 3 git_check_error(rc);
45 3 GIT_NEW_OBJ_WITH_MAGIC(
46 RETVAL, class, note, SvRV(repo)
47 );
48  
49 OUTPUT: RETVAL
50  
51 SV *
52 read(class, repo, commitish, ...)
53 const char *class
54 SV *repo
55 SV *commitish
56  
57 PROTOTYPE: $$$;$
58 PREINIT:
59 int rc;
60  
61 Note note;
62 Repository repo_ptr;
63  
64 git_oid oid;
65  
66 5 const char *ref_name = NULL;
67  
68 CODE:
69 5 ▶ if (items == 4)
Branch: 1 branch
BranchTrueFalseTotal
if (items == 4) 2 3 5
70 2 ref_name = git_ensure_pv(ST(3), "refname");
71  
72 5 repo_ptr = GIT_SV_TO_PTR(Repository, repo);
73  
74 5 rc = git_note_read(
75 &note, repo_ptr -> repository, ref_name,
76 5 git_sv_to_commitish(repo_ptr -> repository, commitish, &oid)
77 );
78  
79 5 RETVAL = &PL_sv_undef;
80 5 ▶ if (rc != GIT_ENOTFOUND) {
Branch: 1 branch
BranchTrueFalseTotal
if (rc != GIT_ENOTFOUND) { 3 2 5
81 3 git_check_error(rc);
82  
83 3 GIT_NEW_OBJ_WITH_MAGIC(
84 RETVAL, "Git::Raw::Note", note, SvRV(repo)
85 );
86 }
87  
88 OUTPUT: RETVAL
89  
90 void
91 remove(class, repo, commitish, ...)
92 const char *class
93 SV *repo
94 SV *commitish
95  
96 PROTOTYPE: $$$;$
97 PREINIT:
98 int rc;
99  
100 Repository repo_ptr;
101 Signature sig;
102  
103 git_oid oid;
104  
105 4 const char *ref_name = NULL;
106  
107 CODE:
108 4 ▶ if (items == 4)
Branch: 1 branch
BranchTrueFalseTotal
if (items == 4) 2 2 4
109 2 ref_name = git_ensure_pv(ST(3), "refname");
110  
111 4 repo_ptr = GIT_SV_TO_PTR(Repository, repo);
112  
113 4 rc = git_signature_default(&sig, repo_ptr -> repository);
114 4 git_check_error(rc);
115  
116 4 rc = git_note_remove(
117 repo_ptr -> repository, ref_name,
118 4 sig, sig, git_sv_to_commitish(repo_ptr -> repository, commitish, &oid)
119 );
120 4 git_signature_free(sig);
121  
122 4 ▶ if (rc != GIT_ENOTFOUND)
Branch: 1 branch
BranchTrueFalseTotal
if (rc != GIT_ENOTFOUND) 2 2 4
123 2 git_check_error(rc);
124  
125 SV *
126 id(self)
127 Note self
128  
129 CODE:
130 3 RETVAL = git_oid_to_sv(git_note_id(self));
131  
132 OUTPUT: RETVAL
133  
134 SV *
135 message(self)
136 Note self
137  
138 CODE:
139 3 RETVAL = newSVpv(git_note_message(self), 0);
140  
141 OUTPUT: RETVAL
142  
143 Signature
144 author(self)
145 Note self
146  
147 PREINIT:
148 int rc;
149 Signature a, r;
150  
151 CODE:
152 1 a = (Signature) git_note_author(self);
153 1 rc = git_signature_dup(&r, a);
154 1 git_check_error(rc);
155  
156 1 RETVAL = r;
157  
158 OUTPUT: RETVAL
159  
160 Signature
161 committer(self)
162 Note self
163  
164 PREINIT:
165 int rc;
166 Signature c, r;
167  
168 CODE:
169 1 c = (Signature) git_note_committer(self);
170 1 rc = git_signature_dup(&r, c);
171 1 git_check_error(rc);
172  
173 1 RETVAL = r;
174  
175 OUTPUT: RETVAL
176  
177 SV *
178 default_ref(class, repo)
179 SV *class
180 SV *repo
181  
182 PREINIT:
183 int rc;
184  
185 Repository repo_ptr;
186 Reference ref;
187  
188 2 git_buf ref_name = GIT_BUF_INIT_CONST(NULL, 0);
189  
190 CODE:
191 2 repo_ptr = GIT_SV_TO_PTR(Repository, repo);
192  
193 2 rc = git_note_default_ref(&ref_name, repo_ptr -> repository);
194 2 git_check_error(rc);
195  
196 2 rc = git_reference_lookup(
197 2 &ref, repo_ptr -> repository, ref_name.ptr
198 );
199 2 git_buf_dispose(&ref_name);
200  
201 2 RETVAL = &PL_sv_undef;
202 2 ▶ if (rc != GIT_ENOTFOUND) {
Branch: 1 branch
BranchTrueFalseTotal
if (rc != GIT_ENOTFOUND) { 1 1 2
203 1 git_check_error(rc);
204  
205 1 GIT_NEW_OBJ_WITH_MAGIC(
206 RETVAL, "Git::Raw::Reference", ref, SvRV(repo)
207 );
208 }
209  
210 OUTPUT: RETVAL
211  
212 void
213 DESTROY(self)
214 SV *self
215  
216 CODE:
217 6 git_note_free(GIT_SV_TO_PTR(Note, self));
218 6 SvREFCNT_dec(GIT_SV_TO_MAGIC(self));
« xs/Mempack.xs ↑ Summary xs/Odb/Backend/OnePack.xs »