File inc/git.inc.php changed (mode: 100644) (index 769a756..bb19231) |
... |
... |
function rg_git_log_simple($repo_path, $max, $from, $to, $also_patch, $files, |
1467 |
1467 |
return $ret; |
return $ret; |
1468 |
1468 |
} |
} |
1469 |
1469 |
|
|
|
1470 |
|
/* |
|
1471 |
|
* Retrieves information about annotated tags. Returned dictionary contains |
|
1472 |
|
* "subject" and "body" fields. Returns FALSE on error and tag not being |
|
1473 |
|
* annotated is considered an error condition. |
|
1474 |
|
*/ |
|
1475 |
|
function rg_git_tag_info($repo_path, $tag) |
|
1476 |
|
{ |
|
1477 |
|
global $rg_git_debug; |
|
1478 |
|
|
|
1479 |
|
$key = 'git' |
|
1480 |
|
. '::' . sha1($repo_path) |
|
1481 |
|
. '::' . 'tag-info' |
|
1482 |
|
. '::' . $tag; |
|
1483 |
|
$r = rg_cache_get($key); |
|
1484 |
|
if ($r !== FALSE) { |
|
1485 |
|
// Cached value is empty for unannotated tags. |
|
1486 |
|
return (empty($r) ? FALSE : $r); |
|
1487 |
|
} |
|
1488 |
|
|
|
1489 |
|
$cmd = "git --no-pager" |
|
1490 |
|
. " --git-dir=" . escapeshellarg($repo_path) |
|
1491 |
|
. " for-each-ref" |
|
1492 |
|
. " --format=\"%(objecttype)\"" |
|
1493 |
|
. " " . escapeshellarg("refs/tags/$tag"); |
|
1494 |
|
$a = rg_exec($cmd, '', FALSE, FALSE, FALSE); |
|
1495 |
|
if ($a['ok'] != 1) { |
|
1496 |
|
rg_internal_error("error on ref info (" . $a['errmsg'] . ")" |
|
1497 |
|
. " cmd=" . $cmd); |
|
1498 |
|
rg_git_set_error("could not check ref type; try again later"); |
|
1499 |
|
return FALSE; |
|
1500 |
|
} |
|
1501 |
|
|
|
1502 |
|
if ($rg_git_debug > 70) |
|
1503 |
|
rg_log_ml("DEBUG: OUTPUT OF GIT FOR-EACH-REF: " . $a['data']); |
|
1504 |
|
|
|
1505 |
|
if ($a['data'] != 'tag') { |
|
1506 |
|
rg_cache_set($key, array(), RG_SOCKET_NO_WAIT); |
|
1507 |
|
return FALSE; |
|
1508 |
|
} |
|
1509 |
|
|
|
1510 |
|
$cmd = "git --no-pager" |
|
1511 |
|
. " --git-dir=" . escapeshellarg($repo_path) |
|
1512 |
|
. " tag" |
|
1513 |
|
. " --list" |
|
1514 |
|
. " --format=\"" |
|
1515 |
|
. "subject:%(contents:subject)%00\"\"" |
|
1516 |
|
. "body:%(contents:body)%00\"\"" |
|
1517 |
|
. "\"" |
|
1518 |
|
. " " . escapeshellarg($tag); |
|
1519 |
|
$a = rg_exec($cmd, '', FALSE, FALSE, FALSE); |
|
1520 |
|
if ($a['ok'] != 1) { |
|
1521 |
|
rg_internal_error("error on tag info (" . $a['errmsg'] . ")" |
|
1522 |
|
. " cmd=" . $cmd); |
|
1523 |
|
rg_git_set_error("could not query tag info; try again later"); |
|
1524 |
|
return FALSE; |
|
1525 |
|
} |
|
1526 |
|
|
|
1527 |
|
if ($rg_git_debug > 70) |
|
1528 |
|
rg_log_ml("DEBUG: OUTPUT OF GIT TAG: " . $a['data']); |
|
1529 |
|
|
|
1530 |
|
$ret = array(); |
|
1531 |
|
|
|
1532 |
|
$x = explode("\0", $a['data']); |
|
1533 |
|
unset($a['data']); // manually free data |
|
1534 |
|
$count = count($x); |
|
1535 |
|
for ($i = 0; $i < $count; $i++) { |
|
1536 |
|
$_t = explode(':', $x[$i], 2); |
|
1537 |
|
if (isset($_t[1])) { |
|
1538 |
|
$ret[$_t[0]] = $_t[1]; |
|
1539 |
|
} else if (empty($_t[0])) { |
|
1540 |
|
// do nothing |
|
1541 |
|
} else { |
|
1542 |
|
//rg_log("DEBUG: Var [" . $_t[0] . "] has no value!"); |
|
1543 |
|
} |
|
1544 |
|
} |
|
1545 |
|
|
|
1546 |
|
rg_cache_set($key, $ret, RG_SOCKET_NO_WAIT); |
|
1547 |
|
return $ret; |
|
1548 |
|
} |
|
1549 |
|
|
1470 |
1550 |
/* |
/* |
1471 |
1551 |
* Works on git_log (without patch) output to detect big diffs. |
* Works on git_log (without patch) output to detect big diffs. |
1472 |
1552 |
* Returns an array with all the info needed to prepare a 'git log'. |
* Returns an array with all the info needed to prepare a 'git log'. |
|
... |
... |
function rg_git_update_tag($db, $a) |
1929 |
2009 |
rg_prof_start("git_update_tag"); |
rg_prof_start("git_update_tag"); |
1930 |
2010 |
rg_log_enter("git_update_tag: " . rg_array2string($a)); |
rg_log_enter("git_update_tag: " . rg_array2string($a)); |
1931 |
2011 |
|
|
|
2012 |
|
// Drop cached information about updated tag. |
|
2013 |
|
|
|
2014 |
|
$key = 'git' |
|
2015 |
|
. '::' . sha1($a['repo_path']) |
|
2016 |
|
. '::' . 'tag-info' |
|
2017 |
|
. '::' . substr($a['refname'], 10); |
|
2018 |
|
rg_cache_unset($key, RG_SOCKET_NO_WAIT); |
|
2019 |
|
|
1932 |
2020 |
$x = array(); |
$x = array(); |
1933 |
2021 |
$x['obj_id'] = $a['repo_id']; |
$x['obj_id'] = $a['repo_id']; |
1934 |
2022 |
$x['type'] = 'repo_refs'; |
$x['type'] = 'repo_refs'; |
|
... |
... |
function rg_git_content_by_file($treeish, $file) |
2393 |
2481 |
rg_prof_start("git_content_by_file"); |
rg_prof_start("git_content_by_file"); |
2394 |
2482 |
rg_log_enter("git_content_by_file: treeish=$treeish file=$file"); |
rg_log_enter("git_content_by_file: treeish=$treeish file=$file"); |
2395 |
2483 |
|
|
|
2484 |
|
// TODO: make this accept $repo_path ? |
2396 |
2485 |
$ret = FALSE; |
$ret = FALSE; |
2397 |
2486 |
while (1) { |
while (1) { |
2398 |
2487 |
$cmd = RG_GIT_CMD . ' show ' . escapeshellarg($treeish) . ':' |
$cmd = RG_GIT_CMD . ' show ' . escapeshellarg($treeish) . ':' |
File inc/user/repo-page.php changed (mode: 100644) (index c0c472e..938436e) |
... |
... |
putenv('GIT_DIR=' . $rg['repo_path']); // TODO: this will be removed after all f |
73 |
73 |
|
|
74 |
74 |
$rg['HTML:menu_repo_level2'] = ''; |
$rg['HTML:menu_repo_level2'] = ''; |
75 |
75 |
$rg['HTML:branches_and_tags'] = ''; |
$rg['HTML:branches_and_tags'] = ''; |
|
76 |
|
$rg['HTML:tag_info'] = ''; |
76 |
77 |
$_repo_body = ""; |
$_repo_body = ""; |
77 |
78 |
|
|
78 |
79 |
// build urls list |
// build urls list |
|
... |
... |
if (strcmp($_subop, "history") == 0) { |
418 |
419 |
|
|
419 |
420 |
rg_add_clone_hints($db, $rg, $ref); |
rg_add_clone_hints($db, $rg, $ref); |
420 |
421 |
|
|
|
422 |
|
if (strcmp($type_ref['ref_type'], "tag") == 0) { |
|
423 |
|
$info = rg_git_tag_info($rg['repo_path'], $type_ref['ref_val']); |
|
424 |
|
if ($info !== FALSE) { |
|
425 |
|
$vars = array_merge($rg, $info); |
|
426 |
|
$rg['HTML:tag_info'] = rg_template("infobox.html", $vars, |
|
427 |
|
TRUE /* xss */); |
|
428 |
|
} |
|
429 |
|
} |
|
430 |
|
|
421 |
431 |
$_repo_body .= rg_template("repo/source.html", $rg, TRUE /*xss*/); |
$_repo_body .= rg_template("repo/source.html", $rg, TRUE /*xss*/); |
422 |
432 |
|
|
423 |
433 |
rg_log("DEBUG: _subsubop=[$_subsubop]"); |
rg_log("DEBUG: _subsubop=[$_subsubop]"); |