xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
Commit cb4bf37be9a40ac50369a48684bf027196fa0c0d

Display tag information when browsing at tags
Information from annotated tags aren't really shown anywhere in the
interface otherwise and yet this is useful thing to look up release data.
Author: xaizek
Author date (UTC): 2019-09-23 16:44
Committer name: xaizek
Committer date (UTC): 2020-07-30 21:15
Parent(s): 2c31f7cbd7b7567cc42dd7762e32d00cb01c2d97
Signing key: 99DC5E4DB05F6BE2
Tree: 3acbdb0c691587bd2c092ca01f9b4e2ead559ba1
File Lines added Lines deleted
inc/git.inc.php 89 0
inc/user/repo-page.php 10 0
root/themes/default/infobox.html 14 0
root/themes/default/main.css 13 1
root/themes/default/repo/source.html 2 0
root/themes/reversed.top/infobox.html 14 0
root/themes/reversed.top/main.css 11 3
root/themes/reversed.top/repo/source.html 2 0
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]");
File root/themes/default/infobox.html added (mode: 100644) (index 0000000..dcb3f82)
1 <div class="infobox">
2 @@if("@@body@@" == ""){{
3 <div class="infobox_header">@@subject@@</div>
4 }}{{
5 <details>
6 <summary>
7 <div class="infobox_header">@@subject@@</div>
8 </summary>
9 <pre>
10 @@body@@
11 </pre>
12 </details>
13 }}
14 </div>
File root/themes/default/main.css changed (mode: 100644) (index e317281..a42bc81)
... ... x.buttons form input[type="submit"], x.buttons form input, x.buttons form select
456 456 background-color: #a0d0ff; background-color: #a0d0ff;
457 457 } }
458 458
459 .hints {
459 .hints, .infobox {
460 460 text-align: left; text-align: left;
461 461 background-color: #fff; background-color: #fff;
462 462 padding: 4pt; padding: 4pt;
 
... ... x.buttons form input[type="submit"], x.buttons form input, x.buttons form select
473 473
474 474 .hint_warn { color: #f00 } .hint_warn { color: #f00 }
475 475
476 .infobox {
477 margin-top: 3pt;
478 margin-bottom: 6pt;
479 }
480 .infobox_header {
481 display: inline-block;
482 font-weight: bold;
483 letter-spacing: 1px;
484 margin-bottom: -4px;
485 }
486 .infobox details :not(:first-child) { margin-top: 4pt }
487
476 488 .bug { .bug {
477 489 display: flex; display: flex;
478 490 flex-flow: column nowrap; flex-flow: column nowrap;
File root/themes/default/repo/source.html changed (mode: 100644) (index 55c3e4a..9b59caf)
1 1 @@branches_and_tags@@ @@branches_and_tags@@
2 2
3 @@tag_info@@
4
3 5 <div class="menu menu3"> <div class="menu menu3">
4 6 <ul> <ul>
5 7 <li@@if(@@source_menu::log@@ == 1){{ class="selected"}}><a href="@@url_repo@@/source/log/@@ref_url@@">Log</a></li> <li@@if(@@source_menu::log@@ == 1){{ class="selected"}}><a href="@@url_repo@@/source/log/@@ref_url@@">Log</a></li>
File root/themes/reversed.top/infobox.html added (mode: 100644) (index 0000000..dcb3f82)
1 <div class="infobox">
2 @@if("@@body@@" == ""){{
3 <div class="infobox_header">@@subject@@</div>
4 }}{{
5 <details>
6 <summary>
7 <div class="infobox_header">@@subject@@</div>
8 </summary>
9 <pre>
10 @@body@@
11 </pre>
12 </details>
13 }}
14 </div>
File root/themes/reversed.top/main.css changed (mode: 100644) (index c5634b7..e040b52)
... ... legend { padding: 0px 2pt; }
510 510 background-color: #a0d0ff; background-color: #a0d0ff;
511 511 } }
512 512
513 .hints {
513 .hints, .infobox {
514 514 text-align: left; text-align: left;
515 515 background-color: #fff; background-color: #fff;
516 padding: 6pt;
517 516 border-radius: 5px 5px 5px 5px; border-radius: 5px 5px 5px 5px;
518 517 border: 1px solid #666; border: 1px solid #666;
519 518 font-size: 9pt; font-size: 9pt;
520 519 align-self: stretch; align-self: stretch;
521 520 } }
522 .hints_header {
521 .hints {
522 padding: 6pt;
523 }
524 .hints_header, .infobox_header {
523 525 display: inline-block; display: inline-block;
524 526 font-weight: bold; font-weight: bold;
525 527 letter-spacing: 1px; letter-spacing: 1px;
 
... ... legend { padding: 0px 2pt; }
532 534
533 535 .hint_warn { color: #f00 } .hint_warn { color: #f00 }
534 536
537 .infobox {
538 margin-top: 5pt;
539 padding: 3pt 6pt;
540 }
541 .infobox details :not(:first-child) { margin-top: 4pt }
542
535 543 .bug { .bug {
536 544 display: flex; display: flex;
537 545 flex-flow: column nowrap; flex-flow: column nowrap;
File root/themes/reversed.top/repo/source.html changed (mode: 100644) (index 4657d1d..be9a732)
1 1 @@branches_and_tags@@ @@branches_and_tags@@
2 2
3 @@tag_info@@
4
3 5 <div class="menu menu3"> <div class="menu menu3">
4 6 <ul> <ul>
5 7 <li@@if(@@source_menu::tree@@ == 1){{ class="selected"}}><a href="@@url_repo@@/source/tree/@@ref_url@@">Tree</a></li> <li@@if(@@source_menu::tree@@ == 1){{ class="selected"}}><a href="@@url_repo@@/source/tree/@@ref_url@@">Tree</a></li>
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://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

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