List of commits:
Subject Hash Author Date (UTC)
Another round of bulk updates cb9dbb75518ab3c214167646197ca7eb0de8e4e6 Catalin(ux) M. BOIE 2011-09-26 19:22:12
Bulk updates cad0c710542dc3fb072268eba40b0abe11217fa9 Catalin(ux) M. BOIE 2011-09-21 20:25:23
Bulk changes. d5274ef5f261086a2af6bd19ac04061bb3d55584 Catalin(ux) M. BOIE 2011-09-15 20:16:46
Store the fist instalation date in 'state' table. e4ba8a9239e72e8de5eed0b3bb1f2a5f2d429105 Catalin(ux) M. BOIE 2011-08-31 16:14:44
Bulk changes. 645d3deb19e399c05a8b14dd88c5151520482b6a Catalin(ux) M. BOIE 2011-08-25 20:39:25
Another bulk update - css related. 3867eb5deadf9827450b40a53efe6c83f518a07b Catalin(ux) M. BOIE 2011-07-26 22:01:13
Bulk update. 9d680f000b7c486be4664e1cb944f424c977c874 Catalin(ux) M. BOIE 2011-07-25 19:06:14
Some ssh and anonymous rights fixes. 9bb20c348a4933056d8f67bd151eb35cf0325835 Catalin(ux) M. BOIE 2011-07-05 22:00:00
Another round of fixes. 45749c46f79f75b29d83ee2d115f987c7765e8c4 Catalin(ux) M. BOIE 2011-07-05 20:01:10
Another round of bulk updates. 6077961d5c443b8a830dc08b3b0ebf37eaf594b3 Catalin(ux) M. BOIE 2011-07-04 22:12:40
Bump version to 0.7. e44064dab5c6f2fa625bb121483a51ec1960cad9 Catalin(ux) M. BOIE 2011-07-03 16:26:47
Lots of changes. 8876190d55995ed98a528edc786e0e9136a0535d Catalin(ux) M. BOIE 2011-07-03 00:03:42
Make %setup quiet as rpmlint told me. b272b9915498fb0a811be2e2687554bbaf887bf1 Catalin(ux) M. BOIE 2011-07-01 03:26:57
Bump version to 0.3 f626f3c66b7b51af2013e16e954e945ba84c12bb Catalin(ux) M. BOIE 2011-07-01 03:25:44
Added logrotate support b827ee7c179d5b72f6ac3ac255edb6de6decb91a Catalin(ux) M. BOIE 2011-07-01 03:25:13
More bulk updates 6dc2b24ebde74bbb64ef2893e2ddb8b7b9456219 Catalin(ux) M. BOIE 2011-07-01 03:16:01
Bulk changes e3771b115feb49698383730893ced1bac5670cac Catalin(ux) M. BOIE 2011-06-29 21:50:03
Ignore Changelog-last file. 32260f93743a577cbaf7cefd335517e4a42edcf0 Catalin(ux) M. BOIE 2011-06-27 21:20:53
Ignore *.out files. 265ba83a2df891cdcc7b35801a46cfc2583983ee Catalin(ux) M. BOIE 2011-06-27 21:20:23
Added shadow-utils as dependency fot user/groupadd. f5816c0bd992881439706041986a3a178eaf69bd Catalin(ux) M. BOIE 2011-06-27 21:08:32
Commit cb9dbb75518ab3c214167646197ca7eb0de8e4e6 - Another round of bulk updates
Author: Catalin(ux) M. BOIE
Author date (UTC): 2011-09-26 19:22
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2011-09-26 19:22
Parent(s): cad0c710542dc3fb072268eba40b0abe11217fa9
Signing key:
Tree: 289c58a32b13735b704d90bf3e81f7a7c3d630f8
File Lines added Lines deleted
TODO 6 0
inc/git.inc.php 157 107
inc/repo.inc.php 19 16
inc/repo/repo.form.php 1 1
inc/repo/repo.php 3 3
inc/user/repo-page.php 19 9
inc/util.inc.php 48 22
root/index.php 7 2
root/themes/default/main.css 7 0
root/themes/default/repo/blob.html 2 0
root/themes/default/repo/diff.html 6 0
root/themes/default/repo/fstat/footer.html 0 0
root/themes/default/repo/fstat/header.html 6 0
root/themes/default/repo/fstat/line.html 5 0
root/themes/default/repo/log/line.html 1 1
scripts/q.php 7 8
scripts/remote.php 9 6
File TODO changed (mode: 100644) (index 8d4583b..fff2353)
96 96 [ ] Show age of an user/org/repo. Example: 1 year, 3 months, 4 days. [ ] Show age of an user/org/repo. Example: 1 year, 3 months, 4 days.
97 97 [ ] The rewrite engine should pass a single op for user and for org, but with para org=0 or 1. [ ] The rewrite engine should pass a single op for user and for org, but with para org=0 or 1.
98 98 This is to have the same page for both types of users. This is to have the same page for both types of users.
99 [ ] From: http://lwn.net/Articles/460376/
100 I can confirm that shortcomings with Gitorious' ACL systems were definitely one of the reasons we ended up deciding against it -- it's just not fine-grained enough and made it impossible to achieve the balance of project maintainer / repo manager autonomy and fool-proofness we wanted. gitolite makes us super-happy in that regard now, though.
101 We use a Gitorious instance where I work. One thing that seems impossible to do is have custom hooks. Everything must go through Gitorious' global hooks. If there's a way around this (new version, black magic, whatever), I'd love to hear it.
102 [ ] Allow git over TLS on a specific port (gits://...).
103 [ ] KDE: http://news.ycombinator.com/item?id=2972107
104 [ ] To investigate how gitolite is dealing with pushes without custom daemon.
99 105 [ ] [ ]
100 106
101 107 == Versus == == Versus ==
File inc/git.inc.php changed (mode: 100644) (index 8873a3e..dfd89e6)
... ... function rg_git_type($obj)
137 137 } }
138 138
139 139 /* /*
140 * Outputs the content of an object
140 * Outputs the content (array) of an object
141 141 */ */
142 142 function rg_git_content($obj) function rg_git_content($obj)
143 143 { {
 
... ... function rg_git_content($obj)
149 149 return FALSE; return FALSE;
150 150 } }
151 151
152 return trim($a);
152 return $output;
153 153 } }
154 154
155 155 /* /*
 
... ... function rg_git_ls_tree($tree)
255 255 return $ret; return $ret;
256 256 } }
257 257
258 /*
259 * Transforms a diff into an array (ready for rg_git_diff)
260 */
261 function rg_git_diff2array($diff)
262 {
263 $ret = array();
264
265 $lines = explode("\n", $diff);
266 $file = 0;
267 foreach ($lines as $line) {
268 if (empty($line))
269 continue;
270
271 if (strncmp($line, "diff ", 5) == 0) {
272 $file++;
273 $ret[$file] = array();
274 $ret[$file]['flags'] = "";
275 $ret[$file]['chunks'] = array();
276 $file_name_sel = "dst";
277 $file_name_tmp = array();
278 continue;
279 }
280
281 if (strncmp($line, "new file ", 9) == 0) {
282 $ret[$file]['flags'] .= "N";
283 continue;
284 }
285
286 if (strncmp($line, "deleted file ", 13) == 0) {
287 $ret[$file]['flags'] .= "D";
288 $file_name_sel = "src";
289 continue;
290 }
291
292 if (strncmp($line, "index ", 6) == 0) {
293 $ret[$file]['index'] = substr($line, 6);
294 continue;
295 }
296
297 if (strncmp($line, "--- ", 4) == 0) {
298 if (strncmp($line, "--- a/", 2) == 0)
299 $file_name_tmp['src'] = substr($line, 6);
300 else
301 $file_name_tmp['src'] = substr($line, 4);
302 continue;
303 }
304
305 if (strncmp($line, "+++ ", 4) == 0) {
306 if (strncmp($line, "+++ b/", 2) == 0)
307 $file_name_tmp['dst'] = substr($line, 6);
308 else
309 $file_name_tmp['dst'] = substr($line, 4);
310 continue;
311 }
312
313 // parse line "@@ -14,6 +14,8 @@ function..."
314 // @@ from_file_range to_file_range @@ ...
315 if (strncmp($line, "@@ ", 3) == 0) {
316 $_t = explode(" ", $line, 5);
317 $chunk = $_t[1] . " " . $_t[2];
318 $ret[$file]['chunks'][$chunk] = array();
319 $ret[$file]['chunks'][$chunk]['section'] = @trim($_t[4]);
320 $from = explode(",", substr($_t[1], 1));
321 $ret[$file]['chunks'][$chunk]['from'] = intval($from[0]);
322 $to = explode(",", substr($_t[2], 1));
323 $ret[$file]['chunks'][$chunk]['to'] = intval($to[0]);
324 continue;
325 }
326
327 if (!isset($file_name_tmp[$file_name_sel])) {
328 echo "bad!";
329 echo $diff;
330 exit(0);
331 }
332
333 if (!isset($ret[$file]['file']))
334 $ret[$file]['file'] = $file_name_tmp[$file_name_sel];
335
336 if ((strncmp($line, " ", 1) == 0)
337 || (strncmp($line, "+", 1) == 0)
338 || (strncmp($line, "-", 1) == 0)) {
339 $ret[$file]['chunks'][$chunk]['lines'][] = $line;
340 continue;
341 }
342
343 echo "I do not know how to parse [" . trim($line) . "]!\n";
344 exit(0);
345 }
346
347 return $ret;
348 }
349
258 350 /* /*
259 351 * Show last @max commits, no merges, sort by topo * Show last @max commits, no merges, sort by topo
260 352 * @also_patch = TRUE if caller needs also the patch * @also_patch = TRUE if caller needs also the patch
261 353 */ */
262 function rg_git_log($max, $also_patch)
354 function rg_git_log($max, $from, $to, $also_patch)
263 355 { {
264 356 rg_log("git_log: max=$max"); rg_log("git_log: max=$max");
265 357
266 358 $max_count = ($max == 0) ? "" : " --max-count=$max"; $max_count = ($max == 0) ? "" : " --max-count=$max";
267 359 $patches = $also_patch ? " --patch" : ""; $patches = $also_patch ? " --patch" : "";
268 360
361 if (empty($from) && empty($to))
362 $from_to = "";
363 else
364 $from_to = " " . $from . ".." . $to;
365
269 366 $cmd = "git log" $cmd = "git log"
270 367 . " --no-merges" . " --no-merges"
271 368 . " -z" . " -z"
 
... ... function rg_git_log($max, $also_patch)
289 386 . "body:%b%x00\"\"" . "body:%b%x00\"\""
290 387 . "notes:%N%x00\"\"" . "notes:%N%x00\"\""
291 388 . "%x00ROCKETGIT_END_OF_VARS%x00\"" . "%x00ROCKETGIT_END_OF_VARS%x00\""
292 . " --numstat";
389 . " --numstat"
390 . $from_to;
293 391 rg_log("\texec $cmd..."); rg_log("\texec $cmd...");
294 392 $a = @exec($cmd, $output, $err); $a = @exec($cmd, $output, $err);
295 393 if ($err != 0) { if ($err != 0) {
 
... ... function rg_git_log($max, $also_patch)
297 395 return FALSE; return FALSE;
298 396 } }
299 397
300 $a = implode("", $output);
398 $a = implode("\n", $output);
301 399
302 400 $blocks = explode("\0-=ROCKETGIT=-\0", $a); $blocks = explode("\0-=ROCKETGIT=-\0", $a);
303 401 // ignore first entry because of separator // ignore first entry because of separator
 
... ... function rg_git_log($max, $also_patch)
309 407
310 408 // split block in two: vars and stats + patches // split block in two: vars and stats + patches
311 409 $parts = explode("\0ROCKETGIT_END_OF_VARS\0", $block, 2); $parts = explode("\0ROCKETGIT_END_OF_VARS\0", $block, 2);
410 //rg_log("DEBUG: parts:" . print_r($parts, TRUE));
312 411
313 412 // vars // vars
314 $x = explode ("\0", $parts[0]);
413 $x = explode ("\0", trim($parts[0]));
315 414 $count = count($x); $count = count($x);
316 415 for ($i = 0; $i < $count - 1; $i++) { for ($i = 0; $i < $count - 1; $i++) {
317 416 $_t = explode(":", $x[$i], 2); $_t = explode(":", $x[$i], 2);
 
... ... function rg_git_log($max, $also_patch)
323 422
324 423 // stats & patches // stats & patches
325 424 $stats_and_patches = trim($parts[1]); $stats_and_patches = trim($parts[1]);
425 rg_log("DEBUG: stats_and_patches:" . print_r($stats_and_patches, TRUE));
326 426 $_sp = explode("\0\0", $stats_and_patches, 2); $_sp = explode("\0\0", $stats_and_patches, 2);
327 427 $stats = $_sp[0]; $stats = $_sp[0];
328 428 if (isset($_sp[1])) if (isset($_sp[1]))
329 $y['patches'] = rg_git_diff2array(trim($_sp[1]));
429 $y['patches'] = rg_git_diff2array($_sp[1]);
330 430
331 431 // stats // stats
332 432 $_t = explode("\0", $stats); $_t = explode("\0", $stats);
 
... ... function rg_git_log($max, $also_patch)
354 454 return $ret; return $ret;
355 455 } }
356 456
357 /*
358 * Transforms a diff into an array (ready for rg_git_diff_template)
359 */
360 function rg_git_diff2array($diff)
361 {
362 $ret = array();
363
364 $lines = explode("\n", $diff);
365 $file = 0;
366 foreach ($lines as $line) {
367 if (strncmp($line, "diff ", 5) == 0) {
368 $file++;
369 $ret[$file] = array();
370 $ret[$file]['flags'] = "";
371 $ret[$file]['chunks'] = array();
372 $file_name_sel = "dst";
373 $file_name_tmp = array();
374 continue;
375 }
376
377 if (strncmp($line, "new file ", 9) == 0) {
378 $ret[$file]['flags'] .= "N";
379 continue;
380 }
381
382 if (strncmp($line, "deleted file ", 13) == 0) {
383 $ret[$file]['flags'] .= "D";
384 $file_name_sel = "src";
385 continue;
386 }
387
388 if (strncmp($line, "index ", 6) == 0) {
389 $ret[$file]['index'] = substr($line, 6);
390 continue;
391 }
392
393 if (strncmp($line, "--- ", 4) == 0) {
394 if (strncmp($line, "--- a/", 2) == 0)
395 $file_name_tmp['src'] = substr($line, 6);
396 else
397 $file_name_tmp['src'] = substr($line, 4);
398 continue;
399 }
400
401 if (strncmp($line, "+++ ", 4) == 0) {
402 if (strncmp($line, "+++ b/", 2) == 0)
403 $file_name_tmp['dst'] = substr($line, 6);
404 else
405 $file_name_tmp['dst'] = substr($line, 4);
406 continue;
407 }
408
409 if (strncmp($line, "@@ ", 3) == 0) {
410 $_t = explode(" ", $line, 5);
411 $chunk = $_t[1] . " " . $_t[2];
412 $ret[$file]['chunks'][$chunk] = array();
413 $ret[$file]['chunks'][$chunk]['section'] = @trim($_t[4]);
414 $lineno = substr($line, 3);
415 $lineno = 0; // TODO: fixit!
416 continue;
417 }
418
419 if (!isset($file_name_tmp[$file_name_sel])) {
420 echo "bad!";
421 echo $diff;
422 exit(0);
423 }
424
425 if (!isset($ret[$file]['file']))
426 $ret[$file]['file'] = $file_name_tmp[$file_name_sel];
427
428 if ((strncmp($line, " ", 1) == 0)
429 || (strncmp($line, "+", 1) == 0)
430 || (strncmp($line, "-", 1) == 0)) {
431 $ret[$file]['chunks'][$chunk]['lines'][$lineno++] = $line;
432 continue;
433 }
434
435 echo "I do not know how to parse [" . trim($line) . "]!\n";
436 exit(0);
437 }
438
439 return $ret;
440 }
441
442 457 /* /*
443 458 * Outputs the result of replacing variables in a template with real variables * Outputs the result of replacing variables in a template with real variables
444 459 */ */
 
... ... function rg_git_stats($log)
511 526 * Outputs the result of replacing variables in a template with real variables * Outputs the result of replacing variables in a template with real variables
512 527 * @a - output of rg_git_diff2array[index] * @a - output of rg_git_diff2array[index]
513 528 */ */
514 function rg_git_diff_template($a, $template_file)
529 function rg_git_diff($a, $template_file)
515 530 { {
531 rg_log("git_diff: a: " . print_r($a, TRUE));
532
516 533 $ret = ""; $ret = "";
517 534
518 535 $template = @file_get_contents($template_file); $template = @file_get_contents($template_file);
 
... ... function rg_git_diff_template($a, $template_file)
520 537 return "Error: cannot load template ($template_file)!"; return "Error: cannot load template ($template_file)!";
521 538
522 539 foreach ($a as $fileindex => $finfo) { foreach ($a as $fileindex => $finfo) {
540 if (!isset($finfo['file']))
541 rg_log("BAD finfo:" . print_r($finfo, TRUE));
523 542 $f = $finfo['file']; $f = $finfo['file'];
543 $ret .= "<br />";
524 544 $ret .= "<b>"; $ret .= "<b>";
525 545 if (strstr($finfo['flags'], "N")) if (strstr($finfo['flags'], "N"))
526 $ret .= "file [$f] added </br/>\n";
546 $ret .= "file [$f] added\n";
527 547 else if (strstr($finfo['flags'], "D")) else if (strstr($finfo['flags'], "D"))
528 $ret .= "file [$f] deleted:<br />";
548 $ret .= "file [$f] deleted:\n";
529 549 else else
530 $ret .= "file [$f] changed:<br />\n";
550 $ret .= "file [$f] changed:\n";
531 551 $ret .= "</b>"; $ret .= "</b>";
532 552
533 553 foreach ($finfo['chunks'] as $chunk => $ci) { foreach ($finfo['chunks'] as $chunk => $ci) {
534 $ret .= "chunk [$chunk], section [" . $ci['section'] . "]:<br />\n";
535 $ret .= "<table border=1>\n";
536 foreach ($ci['lines'] as $line_no => $line) {
554 $ret .= "<br />";
555 $ret .= "Section [" . $ci['section'] . "] ($chunk):<br />\n";
556 $ret .= "<table>\n";
557
558 $line_no_left = $ci['from'];
559 $line_no_right = $ci['to'];
560 foreach ($ci['lines'] as $line) {
537 561 $v = $template; $v = $template;
538 562
539 563 $left_color = "#eeeeee"; $left_color = "#eeeeee";
 
... ... function rg_git_diff_template($a, $template_file)
541 565
542 566 $c = substr($line, 0, 1); $c = substr($line, 0, 1);
543 567 $line = substr($line, 1); $line = substr($line, 1);
544 if (strcmp($c, " ") == 0) {
545 $left = $line;
546 $right = $line;
547 } else if (strcmp($c, "+") == 0) {
568 if (strcmp($c, "+") == 0) {
548 569 $left = ""; $left = "";
549 570 $right = $line; $right = $line;
550 571 $right_color = "#00ff00"; $right_color = "#00ff00";
572 $line_left = "&nbsp;";
573 $line_right = $line_no_right;
574 $line_no_right++;
551 575 } else if (strcmp($c, "-") == 0) { } else if (strcmp($c, "-") == 0) {
552 576 $left = $line; $left = $line;
553 577 $left_color = "#ff0000"; $left_color = "#ff0000";
554 578 $right = ""; $right = "";
555 } else {
556 echo "Something wrong with [$line]!\n";
557 exit(0);
579 $line_left = $line_no_left;
580 $line_right = "&nbsp;";
581 $line_no_left++;
582 } else { // ' ' or any other character
583 $left = $line;
584 $right = $line;
585 $line_left = $line_no_left;
586 $line_right = $line_no_right;
587 $line_no_left++;
588 $line_no_right++;
558 589 } }
559 590
560 $v = preg_replace("/@@line@@/", $line_no, $v);
591 $v = preg_replace("/@@line_left@@/", $line_left, $v);
592 $v = preg_replace("/@@line_right@@/", $line_right, $v);
561 593 $v = preg_replace("/@@left@@/", htmlspecialchars($left), $v); $v = preg_replace("/@@left@@/", htmlspecialchars($left), $v);
562 594 $v = preg_replace("/@@right@@/", htmlspecialchars($right), $v); $v = preg_replace("/@@right@@/", htmlspecialchars($right), $v);
563 595
 
... ... function rg_git_diff_template($a, $template_file)
572 604 return $ret; return $ret;
573 605 } }
574 606
607 /*
608 * Show stats for files changed
609 */
610 function rg_git_files_stats($a, $theme_dir)
611 {
612 $t = array();
613 foreach ($a as $file => $info) {
614 $line = array();
615 $line['file'] = $file;
616 $line['add'] = $info['add'];
617 $line['del'] = $info['del'];
618 $t[] = $line;
619 }
620
621 $more = array();
622 return rg_template_table($theme_dir, $t, $more);
623 }
624
575 625 ?> ?>
File inc/repo.inc.php changed (mode: 100644) (index d783a35..10267db)
... ... function rg_repo_info($db, $rr)
112 112 } else if (!empty($user) && !empty($repo)) { } else if (!empty($user) && !empty($repo)) {
113 113 $ui = rg_user_info($db, 0, $user, ""); $ui = rg_user_info($db, 0, $user, "");
114 114 if ($ui['ok'] != 1) { if ($ui['ok'] != 1) {
115 $ret['errmsg'] = "Invalid repo path (user)";
115 rg_repo_set_error("invalid repo path (user)");
116 116 return $ret; return $ret;
117 117 } }
118 118 $e_repo = rg_sql_escape($db, $repo); $e_repo = rg_sql_escape($db, $repo);
119 119 $add = " uid = " . $ui['uid'] . " AND name = '$e_repo'"; $add = " uid = " . $ui['uid'] . " AND name = '$e_repo'";
120 120 } else { } else {
121 $ret['errmsg'] = "No repo_id or user/name specified!";
121 rg_repo_set_error("no repo_id or user/name specified!");
122 122 return $ret; return $ret;
123 123 } }
124 124
125 125 $sql = "SELECT * FROM repos WHERE " . $add; $sql = "SELECT * FROM repos WHERE " . $add;
126 126 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
127 127 if ($res === FALSE) { if ($res === FALSE) {
128 $ret['errmsg'] = "Cannot query (" . rg_sql_error() . ")";
129 rg_log("\t" . $ret['errmsg']);
128 rg_repo_set_error("cannot query (" . rg_sql_error() . ")");
130 129 return $ret; return $ret;
131 130 } }
132 131 $ret['ok'] = 1; $ret['ok'] = 1;
 
... ... function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size,
205 204 return FALSE; return FALSE;
206 205
207 206 // First, test if it already exists // First, test if it already exists
208 $ri = rg_repo_info($db, 0, $name);
207 $rr = array("user" => $rg_ui['username'], "repo" => $name);
208 $ri = rg_repo_info($db, $rr);
209 209 if ($ri['ok'] != 1) if ($ri['ok'] != 1)
210 210 return FALSE; return FALSE;
211 211 if ($ri['exists'] == 1) { if ($ri['exists'] == 1) {
 
... ... function rg_repo_list_query($db, $url, $sql)
330 330 $_line = array(); $_line = array();
331 331
332 332 foreach ($row as $k => $v) foreach ($row as $k => $v)
333 $_line[$k] = htmlspecialchars($v);
333 $_line[$k] = $v;
334 334
335 335 $_ui = rg_user_info($db, $row['uid'], "", ""); $_ui = rg_user_info($db, $row['uid'], "", "");
336 336 if ($_ui['exists'] != 1) { if ($_ui['exists'] != 1) {
337 $v = "?" . $row['uid'] . "?";
338 $organization = 0;
339 } else {
340 $v = $_ui['username'];
341 $organization = $_ui['organization'];
337 rg_repo_set_error("user associated with this repo not found");
338 return FALSE;
342 339 } }
343 $_line['owner'] = htmlspecialchars($v);
340 $_line['owner'] = $_ui['username'];
344 341
345 $_line['link'] = rg_re_repopage($organization, $_line['owner'],
346 $row['name']);
342 $rr = array(
343 "type" => ($_ui['organization'] == 1) ? "org" : "user",
344 "user" => $_ui['username'],
345 "repo" => $row['name']
346 );
347 $_line['link'] = rg_re_repopage($rr);
347 348
348 $_line['description'] = nl2br(htmlspecialchars($row['description']));
349 $_line['HTML:description'] = nl2br(htmlspecialchars($row['description']));
349 350
350 351 $master_repo = "-"; $master_repo = "-";
351 352 if ($row['master'] > 0) { if ($row['master'] > 0) {
 
... ... function rg_repo_list_query($db, $url, $sql)
354 355 if ($_mi['exists'] = 1) if ($_mi['exists'] = 1)
355 356 $master_repo = $_mi['name']; $master_repo = $_mi['name'];
356 357 } }
357 $_line['clone_of'] = htmlspecialchars($master_repo);
358 $_line['clone_of'] = $master_repo;
358 359 $_line['creation'] = gmdate("Y-m-d H:i:s", $row['itime']); $_line['creation'] = gmdate("Y-m-d H:i:s", $row['itime']);
359 360
360 361 // rights // rights
 
... ... function rg_repo_rights_get($db, $ri, $uid, $flags)
478 479 return $ret; return $ret;
479 480 } }
480 481 } else { } else {
482 rg_log("\tuid $uid is NOT the owner (" . $ri['uid'] . ");"
483 . " assign default rights.");
481 484 $rights = $ri['default_rights']; $rights = $ri['default_rights'];
482 485 } }
483 486
File inc/repo/repo.form.php changed (mode: 100644) (index cb59087..31a671e)
... ... if (count($errmsg) > 0)
5 5 $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n"; $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n";
6 6
7 7 $_form .= ' $_form .= '
8 <form method="post" action="' . rg_re_post($op) . '">
8 <form method="post" action="' . rg_re_post($op) . '/create">
9 9 <input type="hidden" name="op" value="' . $op . '" /> <input type="hidden" name="op" value="' . $op . '" />
10 10 <input type="hidden" name="subop" value="' . $subop . '" /> <input type="hidden" name="subop" value="' . $subop . '" />
11 11 <input type="hidden" name="repo_id" value="' . $repo_id . '" /> <input type="hidden" name="repo_id" value="' . $repo_id . '" />
File inc/repo/repo.php changed (mode: 100644) (index fd8e8ca..f3f788a)
... ... $_url = rg_re_url($op);
25 25 $second_menu = array( $second_menu = array(
26 26 "create_repo" => array( "create_repo" => array(
27 27 "text" => "Create", "text" => "Create",
28 "url" => "&amp;subop=create"
28 "url" => "/create"
29 29 ), ),
30 30 "list_repos" => array( "list_repos" => array(
31 31 "text" => "List", "text" => "List",
32 "url" => "&amp;subop=list"
32 "url" => "/list"
33 33 ), ),
34 34 "search_repo" => array( "search_repo" => array(
35 35 "text" => "Search", "text" => "Search",
36 "url" => "&amp;subop=search"
36 "url" => "/search"
37 37 ) )
38 38 ); );
39 39
File inc/user/repo-page.php changed (mode: 100644) (index 85aa2e4..05c84d4)
... ... if (rg_repo_ok($repo) !== TRUE) {
13 13 return; return;
14 14 } }
15 15
16 $rr = array("user" => $user, "repo" => $repo);
17 16 $ri = rg_repo_info($db, $rr); $ri = rg_repo_info($db, $rr);
18 17 if ($ri === FALSE) { if ($ri === FALSE) {
19 18 $_home .= "Internal error!"; $_home .= "Internal error!";
 
... ... if ($ri === FALSE) {
22 21
23 22 $_more = array( $_more = array(
24 23 "owner" => $user, "owner" => $user,
25 "url" => rg_re_repopage($ri['organization'], $user, $repo),
24 "url" => rg_re_repopage($rr),
26 25 ); );
27 26 $_home .= rg_template($THEME . "/repo/main.html", $ri, $_more); $_home .= rg_template($THEME . "/repo/main.html", $ri, $_more);
28 27
29 $type = ($ri['organization'] == 1) ? "" : "user";
30 $rr = array("type" => $type, "user" => $user, "repo" => $repo);
31 28 $repo_dir = rg_repo_name2base($rr) . $repo . ".git"; $repo_dir = rg_repo_name2base($rr) . $repo . ".git";
32
33 29 putenv("GIT_DIR=$repo_dir"); putenv("GIT_DIR=$repo_dir");
34 30
35 31 if (strcmp($subop, "tree") == 0) { if (strcmp($subop, "tree") == 0) {
 
... ... if (strcmp($subop, "tree") == 0) {
38 34 $_home .= rg_template_table($THEME . "/repo/tree", $_tree, $_more); $_home .= rg_template_table($THEME . "/repo/tree", $_tree, $_more);
39 35 } else if (strcmp($subop, "blob") == 0) { } else if (strcmp($subop, "blob") == 0) {
40 36 $obj = rg_git_reference($paras[0]); $obj = rg_git_reference($paras[0]);
37 $c = rg_git_content($obj);
41 38 $blob = array( $blob = array(
42 39 "obj" => $obj, "obj" => $obj,
43 "content" => rg_git_content($obj)
40 "HTML:content" => rg_template_list($c)
44 41 ); );
45 42 $_home .= rg_template($THEME . "/repo/blob.html", $blob, $_more); $_home .= rg_template($THEME . "/repo/blob.html", $blob, $_more);
46 43 } else { // log } else { // log
47 $log = rg_git_log(10, FALSE);
48 rg_log("log: " . print_r($log, TRUE));
49 $_home .= rg_git_log_template($log, $THEME . "/repo/log", $_more);
44 $commit = rg_git_reference($paras[0]);
45 if (empty($commit)) {
46 $log = rg_git_log(10, "", "", FALSE);
47 rg_log("log: " . print_r($log, TRUE));
48 $_home .= rg_git_log_template($log, $THEME . "/repo/log", $_more);
49 } else {
50 $log = rg_git_log(1, $commit . "~1", $commit, TRUE);
51 rg_log("log: " . print_r($log, TRUE));
52
53 // stats
54 $_home .= rg_git_files_stats($log[0]['files'], $THEME . "/repo/fstat");
55
56 // diff
57 //rg_log("patch: " . print_r($log[0]['patches'], TRUE));
58 $_home .= rg_git_diff($log[0]['patches'], $THEME . "/repo/diff.html");
59 }
50 60 } }
51 61
52 62 ?> ?>
File inc/util.inc.php changed (mode: 100644) (index 70db616..70432b0)
... ... function rg_re_post($op)
93 93 return "/"; return "/";
94 94 } }
95 95
96 function rg_re_repopage($org, $owner, $repo_name)
96 function rg_re_repopage($rr)
97 97 { {
98 if ($org == 0)
98 if (strcmp($rr['type'], "user") == 0)
99 99 $prefix = "/user"; $prefix = "/user";
100 100 else else
101 101 $prefix = ""; $prefix = "";
102 102
103 $s = $prefix . "/" . $owner . "/" . $repo_name;
103 $s = $prefix . "/" . $rr['user'] . "/" . $rr['repo'];
104 104
105 105 if (isset($_REQUEST['rwe'])) if (isset($_REQUEST['rwe']))
106 106 return $s; return $s;
 
... ... function rg_menu($a, $rg_ui)
235 235 return $ret; return $ret;
236 236 } }
237 237
238 function rg_prepare_replace(&$data, &$what, &$values)
239 {
240 if (count($data) == 0)
241 return;
242
243 foreach ($data as $k => $v) {
244 if (strncmp($k, "HTML:", 5) == 0) {
245 $k = substr($k, 5);
246 } else {
247 $v = htmlspecialchars($v);
248 }
249 $what[] = "/@@" . $k . "@@/";
250 $values[] = $v;
251 }
252 }
253
238 254 /* /*
239 255 * Builds a html output based on a template with header, footer and line * Builds a html output based on a template with header, footer and line
240 256 */ */
241 257 function rg_template_table($dir, $data, $more) function rg_template_table($dir, $data, $more)
242 258 { {
259 rg_log("template_table($dir)");
260
243 261 $head = @file_get_contents($dir . "/header.html"); $head = @file_get_contents($dir . "/header.html");
244 262 if ($head === FALSE) if ($head === FALSE)
245 263 $head = ""; $head = "";
 
... ... function rg_template_table($dir, $data, $more)
252 270 if ($foot === FALSE) if ($foot === FALSE)
253 271 $foot = ""; $foot = "";
254 272
255 foreach ($more as $k => $v) {
256 $m_what[] = "/@@" . $k . "@@/";
257 $m_values[] = htmlspecialchars($v);
258 }
273 $m_what = array(); $m_values = array();
274 rg_prepare_replace($more, $m_what, $m_values);
259 275
260 276 $head = preg_replace($m_what, $m_values, $head); $head = preg_replace($m_what, $m_values, $head);
261 277 $foot = preg_replace($m_what, $m_values, $foot); $foot = preg_replace($m_what, $m_values, $foot);
262 278
263 279 $body = ""; $body = "";
264 280 foreach ($data as $index => $info) { foreach ($data as $index => $info) {
265 $what = $m_what;
266 $values = $m_values;
281 $what = $m_what; $values = $m_values;
267 282
268 foreach ($info as $k => $v) {
269 $what[] = "/@@" . $k . "@@/";
270 $values[] = htmlspecialchars($v);
271 }
283 rg_prepare_replace($info, $what, $values);
272 284
273 285 $body .= preg_replace($what, $values, $line); $body .= preg_replace($what, $values, $line);
274 286 } }
 
... ... function rg_template_table($dir, $data, $more)
278 290
279 291 function rg_template($file, $data, $more) function rg_template($file, $data, $more)
280 292 { {
293 rg_log("template($file)");
294
281 295 $body = @file_get_contents($file); $body = @file_get_contents($file);
282 296 if ($body === FALSE) if ($body === FALSE)
283 297 return ""; return "";
 
... ... function rg_template($file, $data, $more)
285 299 $what = array(); $what = array();
286 300 $values = array(); $values = array();
287 301
288 foreach ($more as $k => $v) {
289 $what[] = "/@@" . $k . "@@/";
290 $values[] = htmlspecialchars($v);
291 }
292
293 foreach ($data as $k => $v) {
294 $what[] = "/@@" . $k . "@@/";
295 $values[] = htmlspecialchars($v);
296 }
302 rg_prepare_replace($more, $what, $values);
303 rg_prepare_replace($data, $what, $values);
297 304
298 305 return preg_replace($what, $values, $body); return preg_replace($what, $values, $body);
299 306 } }
300 307
308 /*
309 * Outputs a numbered list
310 */
311 function rg_template_list($a)
312 {
313 if (count($a) == 0)
314 return "";
315
316 $ret = "";
317 $i = 1;
318 $add = "";
319 foreach ($a as $line) {
320 $ret .= $add . $i . "&nbsp;" . htmlspecialchars($line);
321 $add = "<br />";
322 $i++;
323 }
324
325 return $ret;
326 }
301 327 ?> ?>
File root/index.php changed (mode: 100644) (index 7ebccc7..80b763e)
... ... rg_log_set_file("/var/log/rocketgit-web/main.log");
24 24
25 25 // Init variables // Init variables
26 26 $op = ""; $subop = ""; $subsubop = ""; $op = ""; $subop = ""; $subsubop = "";
27 $user = ""; $repo = "";
27 $user = ""; $repo = ""; $organization = 0;
28 28 $paras = array(); $paras = array();
29 29
30 30 // We have variable 'vv' passed from webserver - build 'op' and rest of paras // We have variable 'vv' passed from webserver - build 'op' and rest of paras
 
... ... if (strncmp($vv, "/op/", 4) == 0) { // command
39 39 $subsubop = $_t[2]; $subsubop = $_t[2];
40 40 } }
41 41 } else { // user or organization } else { // user or organization
42 if (strncmp($vv, "/user/", 6) == 0)
42 if (strncmp($vv, "/user/", 6) == 0) {
43 43 $vv = substr($vv, 6); $vv = substr($vv, 6);
44 $type = "user";
45 } else {
46 $type = "org";
47 }
44 48 $_t = explode("/", $vv); $_t = explode("/", $vv);
45 49 $user = $_t[0]; $user = $_t[0];
46 50 if (isset($_t[1])) { if (isset($_t[1])) {
 
... ... if (strncmp($vv, "/op/", 4) == 0) { // command
61 65 $op = "home-page"; $op = "home-page";
62 66 } }
63 67 } }
68 $rr = array("type" => $type, "user" => $user,"repo" => $repo);
64 69
65 70 $doit = rg_var_uint("doit"); $doit = rg_var_uint("doit");
66 71 $sid = rg_var_re("sid", "/[^A-Za-z0-9]/"); $sid = rg_var_re("sid", "/[^A-Za-z0-9]/");
File root/themes/default/main.css changed (mode: 100644) (index 1e0332e..a0391c8)
... ... body {
2 2 margin: 5px; margin: 5px;
3 3 font-family: Verdana, arial, helvetica, sans-serif; font-family: Verdana, arial, helvetica, sans-serif;
4 4 font-size: 14px; font-size: 14px;
5 line-height: 15px;
5 6 } }
6 7
7 8 table { table {
 
... ... th, td {
18 19 text-align: left; text-align: left;
19 20 padding: 3px; padding: 3px;
20 21 border: 1px solid #aaaaaa; border: 1px solid #aaaaaa;
22 white-space: pre;
21 23 } }
22 24
23 25 .white_border { .white_border {
 
... ... th, td {
118 120 font-size: 14px; font-size: 14px;
119 121 color: red; color: red;
120 122 } }
123
124 .source {
125 font-family: monospace;
126 font-size: 11px;
127 }
File root/themes/default/repo/blob.html changed (mode: 100644) (index 2e5dc1c..4ea234b)
1 1 <span class="blob_title">Blob <a href="@@url@@/blob/@@obj@@">@@obj@@</a></span><br /> <span class="blob_title">Blob <a href="@@url@@/blob/@@obj@@">@@obj@@</a></span><br />
2 2 <br /> <br />
3 3
4 <div class="source">
4 5 <pre> <pre>
5 6 @@content@@ @@content@@
6 7 </pre> </pre>
8 </div>
File root/themes/default/repo/diff.html added (mode: 100644) (index 0000000..0cbae79)
1 <tr>
2 <td>@@line_left@@</td>
3 <td>@@line_right@@</td>
4 <td bgcolor="@@left_color@@">@@left@@</td>
5 <td bgcolor="@@right_color@@">@@right@@</td>
6 </tr>
File root/themes/default/repo/fstat/footer.html copied from file root/themes/default/repo/list/footer.html (similarity 100%)
File root/themes/default/repo/fstat/header.html added (mode: 100644) (index 0000000..73eefdd)
1 <table>
2 <tr>
3 <th>File</th>
4 <th>Lines added</th>
5 <th>Lines deleted</th>
6 </tr>
File root/themes/default/repo/fstat/line.html added (mode: 100644) (index 0000000..4f3b893)
1 <tr>
2 <td>@@file@@</td>
3 <td>@@add@@</td>
4 <td>@@del@@</td>
5 </tr>
File root/themes/default/repo/log/line.html changed (mode: 100644) (index 1f68ab2..76683d6)
1 1 <tr> <tr>
2 2 <td>@@subject@@</td> <td>@@subject@@</td>
3 <td>@@sha1_short@@</td>
3 <td><a href="@@url@@/log/@@sha1_short@@">@@sha1_short@@</a></td>
4 4 <td>@@author name@@ (@@author email@@)</td> <td>@@author name@@ (@@author email@@)</td>
5 5 <td>@@author date UTC@@</td> <td>@@author date UTC@@</td>
6 6 <td>@@files_changed@@</td> <td>@@files_changed@@</td>
File scripts/q.php changed (mode: 100644) (index cc553b1..4ef1fd6)
... ... while (TRUE) {
61 61 exit(1); exit(1);
62 62 } }
63 63 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
64 $type = ($row['organization'] == 1) ? "org" : "user";
65
66 rg_log("\tProcessing $type/" . $row['username']
67 . "/" . $row['name'] . "...");
68
69 $rr = array("type" => $type,
64 $rr = array(
65 "type" => ($row['organization'] == 1) ? "org" : "user",
70 66 "user" => $row['username'], "user" => $row['username'],
71 67 "repo" => $row['name']); "repo" => $row['name']);
68
69 rg_log("\tProcessing " . implode("|", $rr) . "...");
70
72 71 $dst = rg_repo_name2base($rr) . $row['name'] . ".git"; $dst = rg_repo_name2base($rr) . $row['name'] . ".git";
73 72 if ($row['master'] == 0) { if ($row['master'] == 0) {
74 73 $r = rg_git_init($dst); $r = rg_git_init($dst);
 
... ... while (TRUE) {
86 85 continue; continue;
87 86 } }
88 87
89 $type = ($mi['organization'] == 1) ? "org" : "user";
90 88 $ui = rg_user_info($db, $mi['uid'], "", ""); $ui = rg_user_info($db, $mi['uid'], "", "");
91 89 if ($ui['ok'] != 1) { if ($ui['ok'] != 1) {
92 90 rg_log("\tCannot lookup uid " rg_log("\tCannot lookup uid "
 
... ... while (TRUE) {
94 92 continue; continue;
95 93 } }
96 94
97 $rr = array("type" => $type,
95 $rr = array(
96 "type" => $mi['organization'] == 1) ? "org" : "user",
98 97 "user" => $ui['username'], "user" => $ui['username'],
99 98 "repo" => $mi['name']); "repo" => $mi['name']);
100 99 $src = rg_repo_name2base($rr) . $mi['name'] . ".git"; $src = rg_repo_name2base($rr) . $mi['name'] . ".git";
File scripts/remote.php changed (mode: 100644) (index 79c7ee6..b616f96)
... ... $_t = trim($_t, "' ");
101 101 $_t = ltrim($_t, "/"); $_t = ltrim($_t, "/");
102 102 $_t = preg_replace('/\.git$/' , '', $_t); $_t = preg_replace('/\.git$/' , '', $_t);
103 103 $_t = explode("/", $_t); $_t = explode("/", $_t);
104 $type = $_t[0];
105 $user = $_t[1];
106 $repo = $_t[2];
104 if (strcmp($_t[0], "user") == 0) {
105 $type = "user";
106 $user = $_t[1];
107 $repo = $_t[2];
108 } else {
109 type = "org";
110 $user = $_t[0];
111 $repo = $_t[1];
112 }
107 113
108 114 rg_log("host=[$host] cmd=[$cmd] type=[$type] user=[$user] repo=[$repo]."); rg_log("host=[$host] cmd=[$cmd] type=[$type] user=[$user] repo=[$repo].");
109 115
110 116 // validity/security checks // validity/security checks
111 if ((strcmp($type, "user") != 0) && (strcmp($type, "org") != 0))
112 fatal("URL is incorrect. You may want to replace [$type] with 'org' or 'user'!");
113
114 117 if (rg_user_ok($user) !== TRUE) if (rg_user_ok($user) !== TRUE)
115 118 fatal("User [$user] is invalid (" . rg_user_error() . ")!"); fatal("User [$user] is invalid (" . rg_user_error() . ")!");
116 119
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main