| File inc/bug.inc.php changed (mode: 100644) (index a4e6963..c06caed) |
| ... |
... |
function rg_bug_vars() |
| 287 |
287 |
*/ |
*/ |
| 288 |
288 |
function rg_bug_cosmetic($db, &$row) |
function rg_bug_cosmetic($db, &$row) |
| 289 |
289 |
{ |
{ |
| 290 |
|
$_ui = rg_user_info($db, $row['uid'], "", ""); |
|
| 291 |
|
if ($_ui['exists'] != 1) |
|
| 292 |
|
$row['owner'] = "?"; |
|
| 293 |
|
else |
|
| 294 |
|
$row['owner'] = $_ui['username']; |
|
| 295 |
|
|
|
| 296 |
|
$row['HTML:body'] = nl2br($row['body']); |
|
| 297 |
|
$row['creation'] = gmdate("Y-m-d H:i", $row['itime']); |
|
| 298 |
|
|
|
| 299 |
|
if ($row['utime'] > 0) |
|
| 300 |
|
$row['updated'] = gmdate("Y-m-d H:i", $row['utime']); |
|
| 301 |
|
else |
|
| 302 |
|
$row['updated'] = "-"; |
|
| 303 |
|
|
|
| 304 |
|
$row['assigned_to'] = ""; |
|
| 305 |
|
if ($row['assigned_uid'] > 0) { |
|
| 306 |
|
$_ui = rg_user_info($db, $row['assigned_uid'], "", ""); |
|
| 307 |
|
if ($_ui['exists'] == 1) |
|
| 308 |
|
$row['assigned_to'] = $_ui['username']; |
|
|
290 |
|
if (isset($row['uid'])) { |
|
291 |
|
$_ui = rg_user_info($db, $row['uid'], "", ""); |
|
292 |
|
if ($_ui['exists'] != 1) |
|
293 |
|
$row['owner'] = "?"; |
|
294 |
|
else |
|
295 |
|
$row['owner'] = $_ui['username']; |
|
296 |
|
} |
|
297 |
|
|
|
298 |
|
if (isset($row['body'])) |
|
299 |
|
$row['HTML:body'] = nl2br($row['body']); |
|
300 |
|
|
|
301 |
|
if (isset($row['itime'])) |
|
302 |
|
$row['creation'] = gmdate("Y-m-d H:i", $row['itime']); |
|
303 |
|
|
|
304 |
|
if (isset($row['utime'])) { |
|
305 |
|
if ($row['utime'] > 0) |
|
306 |
|
$row['updated'] = gmdate("Y-m-d H:i", $row['utime']); |
|
307 |
|
else |
|
308 |
|
$row['updated'] = "-"; |
| 309 |
309 |
} |
} |
| 310 |
310 |
|
|
| 311 |
|
$row['deleted_text'] = ""; |
|
| 312 |
|
$row['deleted_who_name'] = ""; |
|
| 313 |
|
if (isset($row['deleted_who']) && ($row['deleted_who'] > 0)) { |
|
| 314 |
|
$_ui = rg_user_info($db, $row['deleted_who'], "", ""); |
|
| 315 |
|
if ($_ui['exists'] == 1) |
|
| 316 |
|
$row['deleted_who_name'] = $_ui['username']; |
|
|
311 |
|
if (isset($row['assigned_uid'])) { |
|
312 |
|
$row['assigned_to'] = ""; |
|
313 |
|
if ($row['assigned_uid'] > 0) { |
|
314 |
|
$_ui = rg_user_info($db, $row['assigned_uid'], "", ""); |
|
315 |
|
if ($_ui['exists'] == 1) |
|
316 |
|
$row['assigned_to'] = $_ui['username']; |
|
317 |
|
} |
|
318 |
|
} |
| 317 |
319 |
|
|
| 318 |
|
$row['deleted_text'] = gmdate("Y-m-d H:i", $row['deleted']); |
|
|
320 |
|
if (isset($row['deleted'])) { |
|
321 |
|
$row['deleted_text'] = ""; |
|
322 |
|
$row['deleted_who_name'] = ""; |
|
323 |
|
if (isset($row['deleted_who']) && ($row['deleted_who'] > 0)) { |
|
324 |
|
$_ui = rg_user_info($db, $row['deleted_who'], "", ""); |
|
325 |
|
if ($_ui['exists'] == 1) |
|
326 |
|
$row['deleted_who_name'] = $_ui['username']; |
|
327 |
|
|
|
328 |
|
$row['deleted_text'] = gmdate("Y-m-d H:i", $row['deleted']); |
|
329 |
|
} |
| 319 |
330 |
} |
} |
| 320 |
331 |
|
|
| 321 |
|
$row['state_text'] = rg_bug_state($row['state']); |
|
|
332 |
|
if (isset($row['state'])) |
|
333 |
|
$row['state_text'] = rg_bug_state($row['state']); |
| 322 |
334 |
} |
} |
| 323 |
335 |
|
|
| 324 |
336 |
/* |
/* |
| |
| ... |
... |
function rg_bug_edit($db, $login_ui, $ri, $data) |
| 444 |
456 |
$data['ip'] = $ip; |
$data['ip'] = $ip; |
| 445 |
457 |
$data['repo_id'] = $ri['repo_id']; |
$data['repo_id'] = $ri['repo_id']; |
| 446 |
458 |
$data['uid'] = $login_ui['uid']; |
$data['uid'] = $login_ui['uid']; |
|
459 |
|
$data['deleted'] = 0; |
| 447 |
460 |
if ($add == 1) { |
if ($add == 1) { |
| 448 |
461 |
$sql = "INSERT INTO bugs (bug_id, itime, utime, repo_id" |
$sql = "INSERT INTO bugs (bug_id, itime, utime, repo_id" |
| 449 |
462 |
. ", uid, ip, title, body, state, assigned_uid" |
. ", uid, ip, title, body, state, assigned_uid" |
| 450 |
463 |
. ", deleted)" |
. ", deleted)" |
| 451 |
464 |
. " VALUES (@@bug_id@@, @@itime@@, 0, @@repo_id@@" |
. " VALUES (@@bug_id@@, @@itime@@, 0, @@repo_id@@" |
| 452 |
465 |
. ", @@uid@@, @@ip@@, @@title@@, @@body@@" |
. ", @@uid@@, @@ip@@, @@title@@, @@body@@" |
| 453 |
|
. ", @@state@@, @@assigned_uid@@, 0)"; |
|
|
466 |
|
. ", @@state@@, @@assigned_uid@@, @@deleted@@)"; |
| 454 |
467 |
} else { |
} else { |
| 455 |
468 |
$sql = "UPDATE bugs SET utime = @@itime@@" |
$sql = "UPDATE bugs SET utime = @@itime@@" |
| 456 |
469 |
. ", title = @@title@@" |
. ", title = @@title@@" |
| File inc/git.inc.php changed (mode: 100644) (index 7165cb0..cd78d8e) |
| ... |
... |
function rg_git_ls_tree($tree, $path) |
| 454 |
454 |
/* |
/* |
| 455 |
455 |
* Transforms a diff into an array (ready for rg_git_diff) |
* Transforms a diff into an array (ready for rg_git_diff) |
| 456 |
456 |
*/ |
*/ |
| 457 |
|
function rg_git_diff2array($diff) |
|
|
457 |
|
function rg_git_diff2array($diff, &$extra) |
| 458 |
458 |
{ |
{ |
| 459 |
459 |
rg_prof_start("git_diff2array"); |
rg_prof_start("git_diff2array"); |
|
460 |
|
//rg_log_ml("DEBUG: git_diff2array: diff: " . $diff); |
| 460 |
461 |
|
|
| 461 |
462 |
$ret = array(); |
$ret = array(); |
| 462 |
463 |
|
|
|
464 |
|
$extra['lines_add'] = 0; |
|
465 |
|
$extra['lines_del'] = 0; |
|
466 |
|
|
| 463 |
467 |
$lines = explode("\n", $diff); |
$lines = explode("\n", $diff); |
|
468 |
|
//rg_log_ml("DEBUG: lines: " . print_r($lines, TRUE)); |
| 464 |
469 |
|
|
| 465 |
|
$file = 0; |
|
|
470 |
|
$file = -1; |
| 466 |
471 |
foreach ($lines as $line) { |
foreach ($lines as $line) { |
| 467 |
|
if (strncmp($line, "diff ", 5) == 0) { |
|
|
472 |
|
//rg_log("DEBUG: line=$line"); |
|
473 |
|
|
|
474 |
|
// format: diff --git a/a b/a |
|
475 |
|
if (strncmp($line, "diff --git ", 11) == 0) { |
| 468 |
476 |
$file++; |
$file++; |
| 469 |
477 |
$ret[$file] = array(); |
$ret[$file] = array(); |
| 470 |
478 |
$ret[$file]['flags'] = ""; |
$ret[$file]['flags'] = ""; |
|
479 |
|
$ret[$file]['old_mode'] = ""; |
|
480 |
|
$ret[$file]['mode'] = ""; |
|
481 |
|
$ret[$file]['similarity'] = ""; |
|
482 |
|
$ret[$file]['dissimilarity'] = ""; |
|
483 |
|
$ret[$file]['lines_add'] = 0; |
|
484 |
|
$ret[$file]['lines_del'] = 0; |
|
485 |
|
|
|
486 |
|
$rest = substr($line, 11); |
|
487 |
|
//rg_log("DEBUG: rest=$rest."); |
|
488 |
|
$rest = str_replace('" "', ' ', $rest); |
|
489 |
|
$rest = trim($rest, '"'); |
|
490 |
|
$rest = substr($rest, 2); /* skip 'a/' */ |
|
491 |
|
$_t = explode(' b/', $rest); |
|
492 |
|
foreach ($_t as &$_file) { |
|
493 |
|
if (strncmp($_file, '"', 1) == 0) |
|
494 |
|
$_file = substr($_file, 1, -1); |
|
495 |
|
$_file = str_replace('\"', '"', $_file); |
|
496 |
|
} |
|
497 |
|
$ret[$file]['file_from'] = $_t[0]; |
|
498 |
|
$ret[$file]['file'] = $_t[1]; |
|
499 |
|
$ret[$file]['index'] = ""; |
| 471 |
500 |
$ret[$file]['chunks'] = array(); |
$ret[$file]['chunks'] = array(); |
| 472 |
|
$file_name_sel = "dst"; |
|
| 473 |
|
$file_name_tmp = array(); |
|
| 474 |
501 |
continue; |
continue; |
| 475 |
502 |
} |
} |
| 476 |
503 |
|
|
| 477 |
|
if (strncmp($line, "new file ", 9) == 0) { |
|
| 478 |
|
$ret[$file]['flags'] .= "N"; |
|
|
504 |
|
if (strncmp($line, "old mode ", 9) == 0) { |
|
505 |
|
$ret[$file]['old_mode'] = substr($line, 9); |
| 479 |
506 |
continue; |
continue; |
| 480 |
507 |
} |
} |
| 481 |
508 |
|
|
| 482 |
|
if (strncmp($line, "deleted file ", 13) == 0) { |
|
|
509 |
|
if (strncmp($line, "new mode ", 9) == 0) { |
|
510 |
|
$ret[$file]['mode'] = substr($line, 9); |
|
511 |
|
continue; |
|
512 |
|
} |
|
513 |
|
|
|
514 |
|
if (strncmp($line, "deleted file mode ", 18) == 0) { |
| 483 |
515 |
$ret[$file]['flags'] .= "D"; |
$ret[$file]['flags'] .= "D"; |
| 484 |
|
$file_name_sel = "src"; |
|
|
516 |
|
$ret[$file]['old_mode'] = substr($line, 18); |
| 485 |
517 |
continue; |
continue; |
| 486 |
518 |
} |
} |
| 487 |
519 |
|
|
| 488 |
|
if (strncmp($line, "index ", 6) == 0) { |
|
| 489 |
|
$ret[$file]['index'] = substr($line, 6); |
|
|
520 |
|
if (strncmp($line, "new file mode ", 14) == 0) { |
|
521 |
|
$ret[$file]['flags'] .= "N"; |
|
522 |
|
$ret[$file]['mode'] = substr($line, 14); |
| 490 |
523 |
continue; |
continue; |
| 491 |
524 |
} |
} |
| 492 |
525 |
|
|
| 493 |
|
if (strncmp($line, "--- ", 4) == 0) { |
|
| 494 |
|
if (strncmp($line, "--- a/", 2) == 0) |
|
| 495 |
|
$file_name_tmp['src'] = substr($line, 6); |
|
| 496 |
|
else |
|
| 497 |
|
$file_name_tmp['src'] = substr($line, 4); |
|
|
526 |
|
if (strncmp($line, "copy from ", 10) == 0) { |
|
527 |
|
$ret[$file]['flags'] .= "C"; |
| 498 |
528 |
continue; |
continue; |
| 499 |
529 |
} |
} |
| 500 |
530 |
|
|
| 501 |
|
if (strncmp($line, "+++ ", 4) == 0) { |
|
| 502 |
|
if (strncmp($line, "+++ b/", 2) == 0) |
|
| 503 |
|
$file_name_tmp['dst'] = substr($line, 6); |
|
| 504 |
|
else |
|
| 505 |
|
$file_name_tmp['dst'] = substr($line, 4); |
|
|
531 |
|
if (strncmp($line, "copy to ", 10) == 0) |
|
532 |
|
continue; |
|
533 |
|
|
|
534 |
|
if (strncmp($line, "rename from ", 12) == 0) { |
|
535 |
|
$ret[$file]['flags'] .= "R"; |
|
536 |
|
continue; |
|
537 |
|
} |
|
538 |
|
|
|
539 |
|
if (strncmp($line, "rename to ", 10) == 0) |
|
540 |
|
continue; |
|
541 |
|
|
|
542 |
|
if (strncmp($line, "similarity index ", 17) == 0) { |
|
543 |
|
$ret[$file]['similarity'] = substr($line, 17); |
|
544 |
|
continue; |
|
545 |
|
} |
|
546 |
|
|
|
547 |
|
if (strncmp($line, "dissimilarity index ", 20) == 0) { |
|
548 |
|
$ret[$file]['dissimilarity'] = substr($line, 20); |
| 506 |
549 |
continue; |
continue; |
| 507 |
550 |
} |
} |
| 508 |
551 |
|
|
|
552 |
|
if (strncmp($line, "index ", 6) == 0) { |
|
553 |
|
$rest = substr($line, 6); |
|
554 |
|
$_t = explode(' ', $rest); |
|
555 |
|
$ret[$file]['index'] = $_t[0]; |
|
556 |
|
if (isset($_t[1])) |
|
557 |
|
$ret[$file]['mode'] = $_t[1]; |
|
558 |
|
continue; |
|
559 |
|
} |
|
560 |
|
|
|
561 |
|
if (strncmp($line, "--- ", 4) == 0) |
|
562 |
|
continue; |
|
563 |
|
|
|
564 |
|
if (strncmp($line, "+++ ", 4) == 0) |
|
565 |
|
continue; |
|
566 |
|
|
| 509 |
567 |
// parse line "@@ -14,6 +14,8 @@ function..." |
// parse line "@@ -14,6 +14,8 @@ function..." |
| 510 |
568 |
// @@ from_file_range to_file_range @@ ... |
// @@ from_file_range to_file_range @@ ... |
| 511 |
|
if (strncmp($line, "@@ ", 3) == 0) { |
|
|
569 |
|
if (strncmp($line, "@@", 2) == 0) { |
|
570 |
|
rg_log("DEBUG: chunks: $line"); |
|
571 |
|
|
| 512 |
572 |
$_t = explode(" ", $line, 5); |
$_t = explode(" ", $line, 5); |
| 513 |
573 |
if (count($_t) < 4) { |
if (count($_t) < 4) { |
| 514 |
|
rg_internal_error("invalid line [$line]: count != 5"); |
|
|
574 |
|
rg_internal_error("invalid line [$line]: count < 4"); |
| 515 |
575 |
return FALSE; |
return FALSE; |
| 516 |
576 |
} |
} |
| 517 |
577 |
$chunk = $_t[1] . " " . $_t[2]; |
$chunk = $_t[1] . " " . $_t[2]; |
| 518 |
578 |
$ret[$file]['chunks'][$chunk] = array(); |
$ret[$file]['chunks'][$chunk] = array(); |
| 519 |
579 |
$ret[$file]['chunks'][$chunk]['section'] = isset($_t[4]) ? trim($_t[4]) : ""; |
$ret[$file]['chunks'][$chunk]['section'] = isset($_t[4]) ? trim($_t[4]) : ""; |
| 520 |
|
$from = explode(",", substr($_t[1], 1)); |
|
| 521 |
|
$ret[$file]['chunks'][$chunk]['from'] = intval($from[0]); |
|
| 522 |
|
$to = explode(",", substr($_t[2], 1)); |
|
| 523 |
|
$ret[$file]['chunks'][$chunk]['to'] = intval($to[0]); |
|
|
580 |
|
|
|
581 |
|
if (strcmp($_t[1], '-1') == 0) { |
|
582 |
|
$from = '1'; |
|
583 |
|
} else { |
|
584 |
|
$from = explode(",", substr($_t[1], 1)); /* split '-14,6'; 1: skip '-' prefix */ |
|
585 |
|
$from = intval($from[0]); |
|
586 |
|
} |
|
587 |
|
$ret[$file]['chunks'][$chunk]['from'] = $from; |
|
588 |
|
|
|
589 |
|
if (strcmp($_t[2], '+1') == 0) { |
|
590 |
|
$to = '1'; |
|
591 |
|
} else { |
|
592 |
|
$to = explode(",", substr($_t[2], 1)); /* split '+14,8'; 1: skip '+' prefix */ |
|
593 |
|
$to = intval($to[0]); |
|
594 |
|
} |
|
595 |
|
$ret[$file]['chunks'][$chunk]['to'] = $to; |
| 524 |
596 |
continue; |
continue; |
| 525 |
597 |
} |
} |
| 526 |
598 |
|
|
| 527 |
|
if (!isset($file_name_tmp[$file_name_sel])) { |
|
| 528 |
|
rg_internal_error("file_name_tmp[$file_name_sel] does not exists" |
|
| 529 |
|
. "; file_name_tmp: " . print_r($file_name_tmp, TRUE)); |
|
| 530 |
|
return FALSE; |
|
|
599 |
|
if (empty($line)) { |
|
600 |
|
//rg_log("\tWARN: empty line [$line]!"); |
|
601 |
|
continue; |
| 531 |
602 |
} |
} |
| 532 |
603 |
|
|
| 533 |
|
if (!isset($ret[$file]['file'])) |
|
| 534 |
|
$ret[$file]['file'] = $file_name_tmp[$file_name_sel]; |
|
|
604 |
|
if (strncmp($line, "\0", 1) == 0) { |
|
605 |
|
//rg_log("\tWARN: \0 line!"); |
|
606 |
|
continue; |
|
607 |
|
} |
| 535 |
608 |
|
|
| 536 |
|
// empty is because somehow git log pass an empty line. |
|
| 537 |
|
// TODO: we should check this theory. |
|
| 538 |
|
if (empty($line) |
|
| 539 |
|
|| (strncmp($line, " ", 1) == 0) |
|
|
609 |
|
if ((strncmp($line, " ", 1) == 0) |
| 540 |
610 |
|| (strncmp($line, "+", 1) == 0) |
|| (strncmp($line, "+", 1) == 0) |
| 541 |
611 |
|| (strncmp($line, "-", 1) == 0)) { |
|| (strncmp($line, "-", 1) == 0)) { |
| 542 |
612 |
$ret[$file]['chunks'][$chunk]['lines'][] = $line; |
$ret[$file]['chunks'][$chunk]['lines'][] = $line; |
|
613 |
|
|
|
614 |
|
if (strncmp($line, '+', 1) == 0) { |
|
615 |
|
$ret[$file]['lines_add']++; |
|
616 |
|
$extra['lines_add']++; |
|
617 |
|
} else if (strncmp($line, '-', 1) == 0) { |
|
618 |
|
$ret[$file]['lines_del']++; |
|
619 |
|
$extra['lines_del']++; |
|
620 |
|
} |
|
621 |
|
|
| 543 |
622 |
continue; |
continue; |
| 544 |
623 |
} |
} |
| 545 |
624 |
|
|
| |
| ... |
... |
function rg_git_diff2array($diff) |
| 549 |
628 |
continue; |
continue; |
| 550 |
629 |
} |
} |
| 551 |
630 |
|
|
| 552 |
|
if (empty($line)) { |
|
| 553 |
|
rg_log("\tWARN: empty line [$line]!"); |
|
| 554 |
|
continue; |
|
| 555 |
|
} |
|
| 556 |
|
|
|
| 557 |
631 |
rg_internal_error("I do not know how to parse [" . trim($line) . "]!"); |
rg_internal_error("I do not know how to parse [" . trim($line) . "]!"); |
| 558 |
632 |
$ret = FALSE; |
$ret = FALSE; |
|
633 |
|
break; |
| 559 |
634 |
} |
} |
| 560 |
635 |
|
|
| 561 |
636 |
rg_prof_end("git_diff2array"); |
rg_prof_end("git_diff2array"); |
| |
| ... |
... |
function rg_git_diff2array($diff) |
| 565 |
640 |
/* |
/* |
| 566 |
641 |
* Show last @max commits, no merges, sort by topo |
* Show last @max commits, no merges, sort by topo |
| 567 |
642 |
* @also_patch = TRUE if caller needs also the patch |
* @also_patch = TRUE if caller needs also the patch |
|
643 |
|
* TODO: $also_merges: remove --no-merges |
| 568 |
644 |
*/ |
*/ |
| 569 |
645 |
function rg_git_log($path, $max, $from, $to, $also_patch) |
function rg_git_log($path, $max, $from, $to, $also_patch) |
| 570 |
646 |
{ |
{ |
| |
| ... |
... |
function rg_git_log($path, $max, $from, $to, $also_patch) |
| 594 |
670 |
$cmd = "git --no-pager" |
$cmd = "git --no-pager" |
| 595 |
671 |
. " --git-dir=" . escapeshellarg($path) |
. " --git-dir=" . escapeshellarg($path) |
| 596 |
672 |
. " log" |
. " log" |
|
673 |
|
. " --find-copies" |
| 597 |
674 |
. " --no-merges" |
. " --no-merges" |
| 598 |
675 |
. " -z" |
. " -z" |
| 599 |
676 |
. $max_count |
. $max_count |
| |
| ... |
... |
function rg_git_log($path, $max, $from, $to, $also_patch) |
| 616 |
693 |
. "body:%b%x00\"\"" |
. "body:%b%x00\"\"" |
| 617 |
694 |
. "notes:%N%x00\"\"" |
. "notes:%N%x00\"\"" |
| 618 |
695 |
. "%x00ROCKETGIT_END_OF_VARS%x00\"" |
. "%x00ROCKETGIT_END_OF_VARS%x00\"" |
| 619 |
|
. " --numstat" |
|
| 620 |
696 |
. $from_to; |
. $from_to; |
| 621 |
697 |
$a = rg_exec($cmd); |
$a = rg_exec($cmd); |
| 622 |
698 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
| |
| ... |
... |
function rg_git_log($path, $max, $from, $to, $also_patch) |
| 625 |
701 |
break; |
break; |
| 626 |
702 |
} |
} |
| 627 |
703 |
|
|
| 628 |
|
// we prepend a \0 because data starts with -=ROCK... |
|
|
704 |
|
//rg_log_ml("DEBUG: OUTPUT OF GIT LOG: " . $a['data']); |
|
705 |
|
|
|
706 |
|
// because data starts with -=ROCK..., we remove it |
|
707 |
|
$a['data'] = substr($a['data'], 14); |
| 629 |
708 |
$blocks = explode("\0-=ROCKETGIT=-\0", "\0" . $a['data']); |
$blocks = explode("\0-=ROCKETGIT=-\0", "\0" . $a['data']); |
| 630 |
|
// ignore first entry because is empty |
|
| 631 |
|
unset($blocks[0]); |
|
| 632 |
709 |
|
|
| 633 |
710 |
$ret = array(); |
$ret = array(); |
| 634 |
711 |
foreach ($blocks as $junk => $block) { |
foreach ($blocks as $junk => $block) { |
| 635 |
|
$y = array("vars" => array(), "files" => array(), "patches" => array()); |
|
|
712 |
|
$y = array("vars" => array(), "files" => array()); |
| 636 |
713 |
|
|
| 637 |
|
// split block in two: vars and stats + patches |
|
|
714 |
|
// split block in two: vars and patches |
| 638 |
715 |
$parts = explode("\0ROCKETGIT_END_OF_VARS\0", $block, 2); |
$parts = explode("\0ROCKETGIT_END_OF_VARS\0", $block, 2); |
| 639 |
716 |
|
|
| 640 |
717 |
// vars |
// vars |
|
718 |
|
$y['vars']['lines_add'] = 0; |
|
719 |
|
$y['vars']['lines_del'] = 0; |
| 641 |
720 |
$x = explode ("\0", trim($parts[0])); |
$x = explode ("\0", trim($parts[0])); |
| 642 |
721 |
$count = count($x); |
$count = count($x); |
| 643 |
722 |
for ($i = 0; $i < $count - 1; $i++) { |
for ($i = 0; $i < $count - 1; $i++) { |
| 644 |
723 |
$_t = explode(":", $x[$i], 2); |
$_t = explode(":", $x[$i], 2); |
| 645 |
|
if (isset($_t[1])) |
|
|
724 |
|
if (isset($_t[1])) { |
| 646 |
725 |
$y['vars'][$_t[0]] = trim($_t[1]); |
$y['vars'][$_t[0]] = trim($_t[1]); |
| 647 |
|
else |
|
| 648 |
|
echo "Var " . $_t[0] . " has no value!\n"; |
|
|
726 |
|
} else if (empty($_t[0])) { |
|
727 |
|
// do nothing |
|
728 |
|
} else { |
|
729 |
|
rg_log("DEBUG: Var [" . $_t[0] . "] has no value!"); |
|
730 |
|
} |
| 649 |
731 |
} |
} |
| 650 |
732 |
|
|
| 651 |
|
// stats & patches |
|
| 652 |
|
$stats_and_patches = trim($parts[1]); |
|
| 653 |
|
$_sp = explode("\0\0", $stats_and_patches, 2); |
|
| 654 |
|
$stats = $_sp[0]; |
|
| 655 |
|
if (isset($_sp[1])) { |
|
| 656 |
|
$y['patches'] = rg_git_diff2array($_sp[1]); |
|
| 657 |
|
if ($y['patches'] === FALSE) |
|
|
733 |
|
// patches |
|
734 |
|
if (isset($parts[1])) { |
|
735 |
|
$y['files'] = rg_git_diff2array($parts[1], $_extra); |
|
736 |
|
if ($y['files'] === FALSE) |
| 658 |
737 |
break; |
break; |
| 659 |
|
} |
|
| 660 |
738 |
|
|
| 661 |
|
// stats |
|
| 662 |
|
$_t = explode("\0", $stats); |
|
| 663 |
|
$y['vars']['files_changed'] = count($_t); |
|
| 664 |
|
$total_add = 0; |
|
| 665 |
|
$total_del = 0; |
|
| 666 |
|
foreach ($_t as $junk => $fi) { |
|
| 667 |
|
$__t = explode("\t", $fi); |
|
| 668 |
|
$y['files'][$__t[2]] = array( |
|
| 669 |
|
"add" => $__t[0], |
|
| 670 |
|
"del" => $__t[1]); |
|
| 671 |
|
$total_add += intval($__t[0]); |
|
| 672 |
|
$total_del += intval($__t[1]); |
|
|
739 |
|
$y['vars']['lines_add'] = $_extra['lines_add']; |
|
740 |
|
$y['vars']['lines_del'] = $_extra['lines_del']; |
| 673 |
741 |
} |
} |
| 674 |
|
$y['vars']['lines_add'] = $total_add; |
|
| 675 |
|
$y['vars']['lines_del'] = $total_del; |
|
| 676 |
742 |
|
|
| 677 |
743 |
// final additions |
// final additions |
| 678 |
744 |
$y['vars']['author date UTC'] = gmdate("Y-m-d H:i:s", $y['vars']['author date']); |
$y['vars']['author date UTC'] = gmdate("Y-m-d H:i:s", $y['vars']['author date']); |
| |
| ... |
... |
function rg_git_files($old, $new) |
| 802 |
868 |
/* |
/* |
| 803 |
869 |
* Nice diff per file |
* Nice diff per file |
| 804 |
870 |
* Outputs the result of replacing variables in a template with real variables |
* Outputs the result of replacing variables in a template with real variables |
| 805 |
|
* @a - output of rg_git_diff2array[index] |
|
|
871 |
|
* @a - output of rg_git_diff2array[index]['files'] |
| 806 |
872 |
* TODO: Switch to rg_template_table? |
* TODO: Switch to rg_template_table? |
| 807 |
873 |
*/ |
*/ |
| 808 |
874 |
function rg_git_diff($a, $template_file) |
function rg_git_diff($a, $template_file) |
| |
| ... |
... |
function rg_git_diff($a, $template_file) |
| 820 |
886 |
if (!isset($finfo['file'])) |
if (!isset($finfo['file'])) |
| 821 |
887 |
rg_log("BAD finfo:" . rg_array2string($finfo)); |
rg_log("BAD finfo:" . rg_array2string($finfo)); |
| 822 |
888 |
|
|
|
889 |
|
rg_log_ml("DEBUG: finfo: " . print_r($finfo, TRUE)); |
|
890 |
|
|
| 823 |
891 |
$ret .= "<br />\n"; |
$ret .= "<br />\n"; |
| 824 |
892 |
|
|
| 825 |
893 |
$f = rg_xss_safe($finfo['file']); |
$f = rg_xss_safe($finfo['file']); |
| |
| ... |
... |
function rg_git_diff($a, $template_file) |
| 830 |
898 |
if (strstr($finfo['flags'], "N")) |
if (strstr($finfo['flags'], "N")) |
| 831 |
899 |
$ret .= "File <b>$f</b> added"; |
$ret .= "File <b>$f</b> added"; |
| 832 |
900 |
else if (strstr($finfo['flags'], "D")) |
else if (strstr($finfo['flags'], "D")) |
| 833 |
|
$ret .= "File <b>$f</b> deleted:"; |
|
|
901 |
|
$ret .= "File <b>$f</b> deleted"; |
|
902 |
|
else if (strstr($finfo['flags'], "C")) |
|
903 |
|
$ret .= "File <b>$f</b> copied from " |
|
904 |
|
. rg_xss_safe($finfo['file_from']); |
|
905 |
|
else if (strstr($finfo['flags'], "R")) |
|
906 |
|
$ret .= "File <b>$f</b> renamed from " |
|
907 |
|
. rg_xss_safe($finfo['file_from']); |
| 834 |
908 |
else |
else |
| 835 |
|
$ret .= "File <b>$f</b> changed:"; |
|
|
909 |
|
$ret .= "File <b>$f</b> changed"; |
|
910 |
|
|
|
911 |
|
if (!empty($finfo['similarity'])) |
|
912 |
|
$ret .= " (similarity " . rg_xss_Safe($finfo['similarity']) . ")"; |
|
913 |
|
|
|
914 |
|
if (!empty($finfo['dissimilarity'])) |
|
915 |
|
$ret .= " (dissimilarity " . rg_xss_safe($finfo['dissimilarity']) . ")"; |
|
916 |
|
|
|
917 |
|
if (!empty($finfo['mode'])) { |
|
918 |
|
$ret .= " (mode: " . rg_xss_safe($finfo['mode']); |
|
919 |
|
if (!empty($finfo['old_mode'])) |
|
920 |
|
$ret .= " -> " . rg_xss_safe($finfo['old_mode']); |
|
921 |
|
$ret .= ")"; |
|
922 |
|
} |
|
923 |
|
|
|
924 |
|
if (!empty($finfo['index'])) |
|
925 |
|
$ret .= " (index " . rg_xss_safe($finfo['index']) . ")"; |
|
926 |
|
|
|
927 |
|
// TODO: Before stats we must show commit hash, author etc. (source/log/commit/xxxxxx) |
|
928 |
|
// TODO: what about commiter and time and rest? |
|
929 |
|
|
|
930 |
|
$ret .= ":"; |
| 836 |
931 |
$ret .= "</td></tr>\n"; |
$ret .= "</td></tr>\n"; |
| 837 |
932 |
|
|
| 838 |
933 |
$empty_line = ""; |
$empty_line = ""; |
| 839 |
934 |
foreach ($finfo['chunks'] as $chunk => $ci) { |
foreach ($finfo['chunks'] as $chunk => $ci) { |
|
935 |
|
//rg_log_ml("DEBUG: ci: " . print_r($ci, TRUE)); |
| 840 |
936 |
$ret .= $empty_line; |
$ret .= $empty_line; |
| 841 |
937 |
$empty_line = "<tr style=\"border: 1px\"><td colspan=\"4\"> </td></tr>\n"; |
$empty_line = "<tr style=\"border: 1px\"><td colspan=\"4\"> </td></tr>\n"; |
| 842 |
938 |
if (!empty($ci['section'])) { |
if (!empty($ci['section'])) { |
| |
| ... |
... |
function rg_git_diff($a, $template_file) |
| 900 |
996 |
|
|
| 901 |
997 |
/* |
/* |
| 902 |
998 |
* Show stats for files changed |
* Show stats for files changed |
|
999 |
|
* @a = rg_git_log[0]['files'] |
| 903 |
1000 |
*/ |
*/ |
| 904 |
1001 |
function rg_git_files_stats($a, $dir) |
function rg_git_files_stats($a, $dir) |
| 905 |
1002 |
{ |
{ |
| 906 |
1003 |
$t = array(); |
$t = array(); |
| 907 |
|
foreach ($a as $file => $info) { |
|
|
1004 |
|
foreach ($a as $index => $info) { |
| 908 |
1005 |
$line = array(); |
$line = array(); |
| 909 |
|
$line['file'] = $file; |
|
| 910 |
|
$line['add'] = $info['add']; |
|
| 911 |
|
$line['del'] = $info['del']; |
|
|
1006 |
|
$line['file'] = $info['file']; |
|
1007 |
|
$line['add'] = $info['lines_add']; |
|
1008 |
|
$line['del'] = $info['lines_del']; |
| 912 |
1009 |
$t[] = $line; |
$t[] = $line; |
| 913 |
1010 |
} |
} |
| 914 |
1011 |
|
|