File TODO changed (mode: 100644) (index c0d4ecd..c735d80) |
8 |
8 |
[ ] "log" does not list last entries! More exactly, seems the owner does not update repo! |
[ ] "log" does not list last entries! More exactly, seems the owner does not update repo! |
9 |
9 |
[ ] @@branch@@ is not defined for merge requests. Should it? Probably yes, to filter them. |
[ ] @@branch@@ is not defined for merge requests. Should it? Probably yes, to filter them. |
10 |
10 |
[ ] Create a repo and click on it; seems we get error (gabi)! |
[ ] Create a repo and click on it; seems we get error (gabi)! |
|
11 |
|
[ ] Enforce Signoff-by lines per project (a new permission) |
|
12 |
|
= reject commits without signoff! |
|
13 |
|
Maybe, do it generic, allow a text field to enumerate what should be in a commit! |
|
14 |
|
Also, present a list with checkboxex: at least Signoff-by, Reported-by, Acked-by! |
11 |
15 |
[ ] |
[ ] |
|
16 |
|
[ ] Check if we have a way to disable merge requests per project. |
|
17 |
|
[ ] Add real name to user info. |
|
18 |
|
[ ] Add permission to add bug tracker to a project. |
|
19 |
|
|
|
20 |
|
== Medium == |
|
21 |
|
[ ] Linus on why GitHub sucks: https://github.com/torvalds/linux/pull/17#issuecomment-5654674 |
|
22 |
|
[ ] Warn if commit messages are too long (no wrap). |
|
23 |
|
[ ] Allow possibility to send an e-mail to mainteiner from web with a pull request |
|
24 |
|
[ ] Check https://github.com/torvalds/linux/pull/17#issuecomment-5654674 |
|
25 |
|
[ ] Merge requests e-mail: explanation of why to pull, diffstat! Maybe also the patch if is small. |
|
26 |
|
[ ] Check git-request-pull |
12 |
27 |
|
|
13 |
28 |
== Normal priority == |
== Normal priority == |
|
29 |
|
[ ] How to sign merge requests?! |
|
30 |
|
[ ] Signal, with red, if a key was uploaded in the last X days. |
|
31 |
|
[ ] Store in a cookie the last uid used, and if > 0, lookup e-mail and prefill |
|
32 |
|
forgot password e-mail field. |
|
33 |
|
[ ] Yeah BitBucket's pricing is much better they only charge on the number of collaborators. |
14 |
34 |
[ ] Permit "log" to see more rows. |
[ ] Permit "log" to see more rows. |
15 |
35 |
[ ] Allow admin to upload keys for a user. |
[ ] Allow admin to upload keys for a user. |
16 |
36 |
[ ] Make an option to not allow a client to upload keys. |
[ ] Make an option to not allow a client to upload keys. |
File inc/bug.inc.php added (mode: 100644) (index 0000000..1fb7fe9) |
|
1 |
|
<?php |
|
2 |
|
require_once($INC . "/util.inc.php"); |
|
3 |
|
require_once($INC . "/log.inc.php"); |
|
4 |
|
require_once($INC . "/sql.inc.php"); |
|
5 |
|
require_once($INC . "/user.inc.php"); |
|
6 |
|
require_once($INC . "/prof.inc.php"); |
|
7 |
|
|
|
8 |
|
$rg_bug_error = ""; |
|
9 |
|
|
|
10 |
|
function rg_bug_set_error($str) |
|
11 |
|
{ |
|
12 |
|
global $rg_bug_error; |
|
13 |
|
|
|
14 |
|
$rg_bug_error = $str; |
|
15 |
|
} |
|
16 |
|
|
|
17 |
|
function rg_bug_error() |
|
18 |
|
{ |
|
19 |
|
global $rg_bug_error; |
|
20 |
|
return $rg_bug_error; |
|
21 |
|
} |
|
22 |
|
|
|
23 |
|
/* |
|
24 |
|
* We want the bug number to be consecutive per project. |
|
25 |
|
* TODO: Big race here, two people can insert the get the same id! |
|
26 |
|
*/ |
|
27 |
|
function rg_bug_next_id($db, $repo_id) |
|
28 |
|
{ |
|
29 |
|
rg_prof_start("bug_next_id"); |
|
30 |
|
|
|
31 |
|
$sql = "SELECT MAX(bug_id) + 1 AS max FROM bugs" |
|
32 |
|
. " WHERE repo_id = $repo_id"; |
|
33 |
|
$res = rg_sql_query($db, $sql); |
|
34 |
|
if ($res === FALSE) { |
|
35 |
|
rg_bug_set_error("cannot get max (" . rg_sql_error() . ")"); |
|
36 |
|
return $ret; |
|
37 |
|
} |
|
38 |
|
$row = rg_sql_fetch_array($res); |
|
39 |
|
rg_log("DEBUG: max=" . $row['max']); |
|
40 |
|
rg_sql_free_result($res); |
|
41 |
|
|
|
42 |
|
rg_prof_end("bug_next_id"); |
|
43 |
|
|
|
44 |
|
return empty($row['max']) ? 1 : $row['max']; |
|
45 |
|
} |
|
46 |
|
|
|
47 |
|
/* |
|
48 |
|
* Return info about a bug |
|
49 |
|
*/ |
|
50 |
|
$rg_bug_info_cache = array(); |
|
51 |
|
function rg_bug_info($db, $repo_id, $bug_id) |
|
52 |
|
{ |
|
53 |
|
global $rg_bug_info_cache; |
|
54 |
|
|
|
55 |
|
rg_prof_start("bug_info"); |
|
56 |
|
|
|
57 |
|
$key = $repo_id . "-" . $bug_id; |
|
58 |
|
if (isset($rg_bug_info_cache[$key])) |
|
59 |
|
return $rg_bug_info_cache[$key]; |
|
60 |
|
|
|
61 |
|
rg_log("bug_info: repo_id=$repo_id bug_id=$bug_id"); |
|
62 |
|
|
|
63 |
|
$ret['ok'] = 0; |
|
64 |
|
$ret['exists'] = 0; |
|
65 |
|
|
|
66 |
|
$rg_bug_info_cache[$key] = $ret; |
|
67 |
|
|
|
68 |
|
$sql = "SELECT * FROM bugs" |
|
69 |
|
. " WHERE repo_id = " . $repo_id |
|
70 |
|
. " AND bug_id = " . $bug_id; |
|
71 |
|
$res = rg_sql_query($db, $sql); |
|
72 |
|
if ($res === FALSE) { |
|
73 |
|
rg_bug_set_error("cannot query (" . rg_sql_error() . ")"); |
|
74 |
|
return $ret; |
|
75 |
|
} |
|
76 |
|
$ret['ok'] = 1; |
|
77 |
|
$row = rg_sql_fetch_array($res); |
|
78 |
|
rg_sql_free_result($res); |
|
79 |
|
if (!isset($row['bug_id'])) { |
|
80 |
|
rg_log("\tBug not found!"); |
|
81 |
|
return $ret; |
|
82 |
|
} |
|
83 |
|
|
|
84 |
|
$row['exists'] = 1; |
|
85 |
|
$row['ok'] = 1; |
|
86 |
|
|
|
87 |
|
$rg_bug_info_cache[$key] = $row; |
|
88 |
|
|
|
89 |
|
rg_prof_end("bug_info"); |
|
90 |
|
|
|
91 |
|
return $row; |
|
92 |
|
} |
|
93 |
|
|
|
94 |
|
/* |
|
95 |
|
* Add a bug |
|
96 |
|
*/ |
|
97 |
|
function rg_bug_add($db, $repo_id, $uid, $data) |
|
98 |
|
{ |
|
99 |
|
rg_prof_start("bug_add"); |
|
100 |
|
|
|
101 |
|
rg_log("bug_add: repo_id=$repo_id uid=$uid" |
|
102 |
|
. " data: " . rg_array2string($data)); |
|
103 |
|
|
|
104 |
|
// TODO: test if user is allowed to add a bug |
|
105 |
|
|
|
106 |
|
$e_data = $data; |
|
107 |
|
$e_data['title'] = rg_sql_escape($db, $data['title']); |
|
108 |
|
$e_data['body'] = rg_sql_escape($db, $data['body']); |
|
109 |
|
$e_data['labels'] = rg_sql_escape($db, $data['labels']); |
|
110 |
|
|
|
111 |
|
$itime = time(); |
|
112 |
|
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ""; |
|
113 |
|
|
|
114 |
|
$bug_id = rg_bug_next_id($db, $repo_id); |
|
115 |
|
if ($bug_id == 0) |
|
116 |
|
return FALSE; |
|
117 |
|
|
|
118 |
|
$sql = "INSERT INTO bugs (bug_id, itime, utime, repo_id, uid, ip" |
|
119 |
|
. ", title, body, labels, state, assigned_uid, deleted)" |
|
120 |
|
. " VALUES ($bug_id, $itime, 0, $repo_id, $uid, '$ip'" |
|
121 |
|
. ", '" . $e_data['title'] . "'" |
|
122 |
|
. ", '" . $e_data['body'] . "'" |
|
123 |
|
. ", '" . $e_data['labels'] . "'" |
|
124 |
|
. ", " . $e_data['state'] |
|
125 |
|
. ", " . $e_data['assigned_uid'] |
|
126 |
|
. ", 0)"; |
|
127 |
|
$res = rg_sql_query($db, $sql); |
|
128 |
|
if ($res === FALSE) { |
|
129 |
|
rg_bug_set_error("Cannot insert bug (" . rg_sql_error() . ")"); |
|
130 |
|
return FALSE; |
|
131 |
|
} |
|
132 |
|
rg_sql_free_result($res); |
|
133 |
|
|
|
134 |
|
rg_prof_end("bug_add"); |
|
135 |
|
|
|
136 |
|
return $bug_id; |
|
137 |
|
} |
|
138 |
|
|
|
139 |
|
/* |
|
140 |
|
* Delete a bug |
|
141 |
|
*/ |
|
142 |
|
function rg_bug_delete($db, $repo_id, $bug_id) |
|
143 |
|
{ |
|
144 |
|
rg_prof_start("bug_delete"); |
|
145 |
|
|
|
146 |
|
rg_log("bug_delete: $repo_id=$repo_id bug_id=$bug_id"); |
|
147 |
|
|
|
148 |
|
// TODO: Check rights |
|
149 |
|
|
|
150 |
|
$now = time(); |
|
151 |
|
|
|
152 |
|
// Only mark it as such, deletion will happen in background |
|
153 |
|
$sql = "UPDATE bugs SET deleted = $now" |
|
154 |
|
. " WHERE repo_id = $repo_id" |
|
155 |
|
. " AND bug_id = $bug_id"; |
|
156 |
|
$res = rg_sql_query($db, $sql); |
|
157 |
|
if ($res === FALSE) { |
|
158 |
|
rg_bug_set_error("Cannot delete bug (" . rg_sql_error() . ")"); |
|
159 |
|
return FALSE; |
|
160 |
|
} |
|
161 |
|
rg_sql_free_result($res); |
|
162 |
|
|
|
163 |
|
rg_prof_end("bug_delete"); |
|
164 |
|
|
|
165 |
|
return TRUE; |
|
166 |
|
} |
|
167 |
|
|
|
168 |
|
/* |
|
169 |
|
* Update a bug |
|
170 |
|
* TODO: check rights - also for create? |
|
171 |
|
*/ |
|
172 |
|
function rg_bug_update($db, $repo_id, $bug_id, $data) |
|
173 |
|
{ |
|
174 |
|
rg_prof_start("bug_update"); |
|
175 |
|
|
|
176 |
|
rg_log("bug_update: repo_id=$repo_id bug_id=$bug_id data: " |
|
177 |
|
. rg_array2string($data)); |
|
178 |
|
|
|
179 |
|
// First, test if it already exists |
|
180 |
|
$bi = rg_bug_info($db, $repoid, $bug_id); |
|
181 |
|
if ($bi['exists'] != 1) |
|
182 |
|
return FALSE; |
|
183 |
|
|
|
184 |
|
$e_data = $data; |
|
185 |
|
$e_data['title'] = rg_sql_escape($db, $data['title']); |
|
186 |
|
$e_data['body'] = rg_sql_escape($db, $data['body']); |
|
187 |
|
$e_data['labels'] = rg_sql_escape($db, $data['labels']); |
|
188 |
|
|
|
189 |
|
$utime = time(); |
|
190 |
|
|
|
191 |
|
$sql = "UPDATE bugs SET utime = $now" |
|
192 |
|
. ", title = '" . $e_data['title'] . "'" |
|
193 |
|
. ", body = '" . $e_data['body'] . "'" |
|
194 |
|
. ", labels = '" . $e_data['labels'] . "'" |
|
195 |
|
. ", state = " . $e_data['state'] |
|
196 |
|
. ", assigned_uid = " . $e_data['assigned_uid'] |
|
197 |
|
. " WHERE repo_id = $repo_id" |
|
198 |
|
. " AND bug_id = $bug_id"; |
|
199 |
|
$res = rg_sql_query($db, $sql); |
|
200 |
|
if ($res === FALSE) { |
|
201 |
|
rg_bug_set_error("Cannot update bug (" . rg_sql_error() . ")"); |
|
202 |
|
return FALSE; |
|
203 |
|
} |
|
204 |
|
rg_sql_free_result($res); |
|
205 |
|
|
|
206 |
|
rg_prof_end("bug_update"); |
|
207 |
|
|
|
208 |
|
return TRUE; |
|
209 |
|
} |
|
210 |
|
|
|
211 |
|
/* |
|
212 |
|
* List bugs |
|
213 |
|
*/ |
|
214 |
|
function rg_bug_list_query($db, $url, $sql) |
|
215 |
|
{ |
|
216 |
|
rg_prof_start("bug_list_query"); |
|
217 |
|
|
|
218 |
|
rg_log("bug_list_query: url=$url, sql=$sql..."); |
|
219 |
|
|
|
220 |
|
$res = rg_sql_query($db, $sql); |
|
221 |
|
if ($res === FALSE) { |
|
222 |
|
rg_bug_set_error("cannot list by query (" . rg_sql_error() . ")"); |
|
223 |
|
return FALSE; |
|
224 |
|
} |
|
225 |
|
|
|
226 |
|
$d = array(); |
|
227 |
|
while (($row = rg_sql_fetch_array($res))) { |
|
228 |
|
$_line = array(); |
|
229 |
|
|
|
230 |
|
foreach ($row as $k => $v) |
|
231 |
|
$_line[$k] = $v; |
|
232 |
|
|
|
233 |
|
$_ui = rg_user_info($db, $row['uid'], "", ""); |
|
234 |
|
if ($_ui['exists'] != 1) |
|
235 |
|
$_line['owner'] = "?"; |
|
236 |
|
else |
|
237 |
|
$_line['owner'] = $_ui['username']; |
|
238 |
|
|
|
239 |
|
$_line['body'] = nl2br(htmlspecialchars($row['body'])); |
|
240 |
|
$_line['creation'] = gmdate("Y-m-d", $row['itime']); |
|
241 |
|
$_line['updated'] = gmdate("Y-m-d", $row['utime']); |
|
242 |
|
|
|
243 |
|
if ($row['assigned_uid'] == 0) { |
|
244 |
|
$_line['assigned_to'] = "-"; |
|
245 |
|
} else { |
|
246 |
|
$_ui = rg_user_info($db, $row['assigned_uid'], "", ""); |
|
247 |
|
if ($_ui['exists'] != 1) { |
|
248 |
|
$_line['assigned_to'] = "?"; |
|
249 |
|
} else { |
|
250 |
|
$_line['assigned_to'] = $_ui['username']; |
|
251 |
|
} |
|
252 |
|
} |
|
253 |
|
|
|
254 |
|
$d[] = $_line; |
|
255 |
|
} |
|
256 |
|
rg_sql_free_result($res); |
|
257 |
|
|
|
258 |
|
rg_prof_end("bug_list_query"); |
|
259 |
|
|
|
260 |
|
return rg_template_table("bug/list", $d, array()); |
|
261 |
|
} |
|
262 |
|
|
|
263 |
|
/* |
|
264 |
|
* |
|
265 |
|
*/ |
|
266 |
|
function rg_bug_list($db, $url, $repo_id) |
|
267 |
|
{ |
|
268 |
|
rg_log("bug_list: url=$url, repo_id=$repo_id"); |
|
269 |
|
|
|
270 |
|
$sql = "SELECT * FROM bugs" |
|
271 |
|
. " WHERE repo_id = $repo_id" |
|
272 |
|
. " ORDER BY itime"; |
|
273 |
|
|
|
274 |
|
return rg_bug_list_query($db, $url, $sql); |
|
275 |
|
} |
|
276 |
|
|
|
277 |
|
/* |
|
278 |
|
* |
|
279 |
|
*/ |
|
280 |
|
function rg_bug_search($db, $q) |
|
281 |
|
{ |
|
282 |
|
rg_log("bug_search: q=$q..."); |
|
283 |
|
|
|
284 |
|
$e_q = rg_sql_escape($db, $q); |
|
285 |
|
|
|
286 |
|
$sql = "SELECT * FROM bugs" |
|
287 |
|
. " WHERE deleted = 0" |
|
288 |
|
. " AND (title ILIKE '%$e_q%' OR body ILIKE '%$e_q%')" |
|
289 |
|
. " ORDER BY itime" |
|
290 |
|
. " LIMIT 10"; |
|
291 |
|
|
|
292 |
|
return rg_bug_list_query($db, "", $sql); |
|
293 |
|
} |
|
294 |
|
|
|
295 |
|
/* |
|
296 |
|
* Add a note for a bug |
|
297 |
|
*/ |
|
298 |
|
function rg_bug_note_add($db, $repo_id, $bug_id, $uid, $data) |
|
299 |
|
{ |
|
300 |
|
rg_prof_start("bug_note_add"); |
|
301 |
|
|
|
302 |
|
rg_log("bug_note_add: repo_id=$repo_id bug_id=$bug_id" |
|
303 |
|
. " data: " . rg_array2string($data)); |
|
304 |
|
|
|
305 |
|
// TODO: test if user is allowed to add a note |
|
306 |
|
|
|
307 |
|
$e_data = $data; |
|
308 |
|
$e_data['note'] = rg_sql_escape($db, $data['note']); |
|
309 |
|
|
|
310 |
|
$itime = time(); |
|
311 |
|
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "?"; |
|
312 |
|
|
|
313 |
|
$sql = "INSERT INTO bug_notes (repo_id, bug_id, itime, uid, ip" |
|
314 |
|
. ", note)" |
|
315 |
|
. " VALUES ($repo_id, $bug_id, $itime, $uid, '$ip'" |
|
316 |
|
. ", '" . $e_data['note'] . "')"; |
|
317 |
|
$res = rg_sql_query($db, $sql); |
|
318 |
|
if ($res === FALSE) { |
|
319 |
|
rg_bug_set_error("Cannot insert bug note (" . rg_sql_error() . ")"); |
|
320 |
|
return FALSE; |
|
321 |
|
} |
|
322 |
|
rg_sql_free_result($res); |
|
323 |
|
|
|
324 |
|
rg_prof_end("bug_note_add"); |
|
325 |
|
|
|
326 |
|
return TRUE; |
|
327 |
|
} |
|
328 |
|
|
|
329 |
|
?> |