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 f82d44b18897564d35c0a133303c3a47e419d38b

Severall small fixes reported by Gabi and James
Author: Catalin(ux) M. BOIE
Author date (UTC): 2012-10-22 03:03
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2012-10-22 03:03
Parent(s): abe986682dea732dbd4248fac63bdd6b015b8f2e
Signing key:
Tree: ff3bad47bb2fc7ce7759613ad61d5d505f0600a6
File Lines added Lines deleted
TODO 4 0
duilder.conf 1 1
hooks/pre-commit 2 0
hooks/pre-receive 3 0
hooks/update 7 4
inc/prof.inc.php 2 0
inc/struct.inc.php 5 0
inc/util.inc.php 29 7
root/index.php 1 1
root/themes/default/index.html 4 2
root/themes/default/main.css 4 7
root/themes/default/main.html 2 1
scripts/cron.php 2 1
scripts/q.php 1 1
scripts/remote.php 2 3
tests/root/themes/util/t3/c6 1 0
tests/root/themes/util/t3/c7 1 0
tests/util.php 20 0
File TODO changed (mode: 100644) (index 7837153..adc2088)
11 11 [ ] Third option: anybody can create an account but must be validated by admin. [ ] Third option: anybody can create an account but must be validated by admin.
12 12 [ ] After creating the account, keep the user logged in and allow login [ ] After creating the account, keep the user logged in and allow login
13 13 even if is not confirmed (option in config). even if is not confirmed (option in config).
14 [ ] Fix the headers (+dkim) to avoid spam.
15 [ ] logrotate is not working.
16 [ ]
14 17
15 18
16 19 == Medium == == Medium ==
20 [ ] Happy birthday for projects/users/etc.
17 21 [ ] Check if if we remove rocketgit, the repos stay! [ ] Check if if we remove rocketgit, the repos stay!
18 22 [ ] Bug rights: add note, anonymous add note, add label, add global search. [ ] Bug rights: add note, anonymous add note, add label, add global search.
19 23 [ ] Allow user to specify if is on windows/linux/etc. to be able to give [ ] Allow user to specify if is on windows/linux/etc. to be able to give
File duilder.conf changed (mode: 100644) (index 4d35852..0a25613)
1 1 PRJ="rocketgit" PRJ="rocketgit"
2 VER="0.12"
2 VER="0.13"
3 3 REV="1" REV="1"
4 4 EXCLUDE=".exclude" EXCLUDE=".exclude"
5 5 EXPORT_PATH="/data/www/umbrella/kernel/us/rocketgit" EXPORT_PATH="/data/www/umbrella/kernel/us/rocketgit"
File hooks/pre-commit changed (mode: 100755) (index 278aee3..a8711da)
... ... require_once($INC . "/git.inc.php");
18 18
19 19 rg_log_set_file($rg_log_dir . "/hook_pre-commit.log"); rg_log_set_file($rg_log_dir . "/hook_pre-commit.log");
20 20
21 $repo_path = getenv("ROCKETGIT_REPO_PATH");
22
21 23 rg_log("Start..."); rg_log("Start...");
22 24 rg_log("_SERVER: " . rg_array2string($_SERVER)); rg_log("_SERVER: " . rg_array2string($_SERVER));
23 25
File hooks/pre-receive changed (mode: 100755) (index a952a41..a7956c0)
... ... require_once($INC . "/repo.inc.php");
23 23
24 24 rg_log_set_file($rg_log_dir . "/hook_pre-receive.log"); rg_log_set_file($rg_log_dir . "/hook_pre-receive.log");
25 25
26 $repo_path = getenv("ROCKETGIT_REPO_PATH");
27 $uid = etenv("ROCKETGIT_UID");
28
26 29 rg_log("Start"); rg_log("Start");
27 30 rg_log("_SERVER: " . rg_array2string($_SERVER)); rg_log("_SERVER: " . rg_array2string($_SERVER));
28 31
File hooks/update changed (mode: 100755) (index 41893c9..515c3d6)
12 12 error_reporting(E_ALL); error_reporting(E_ALL);
13 13 ini_set("track_errors", "On"); ini_set("track_errors", "On");
14 14
15 $_start = microtime(TRUE);
16
15 17 require_once("/etc/rocketgit/config.php"); require_once("/etc/rocketgit/config.php");
16 18
17 19 $INC = $rg_scripts . "/inc"; $INC = $rg_scripts . "/inc";
 
... ... $a['rights'] = getenv("ROCKETGIT_REPO_RIGHTS");
33 35 $a['repo_id'] = getenv("ROCKETGIT_REPO_ID"); $a['repo_id'] = getenv("ROCKETGIT_REPO_ID");
34 36 $a['ip'] = getenv("ROCKETGIT_IP"); $a['ip'] = getenv("ROCKETGIT_IP");
35 37 $a['namespace'] = getenv("GIT_NAMESPACE"); $a['namespace'] = getenv("GIT_NAMESPACE");
38 $a['repo_path'] = getenv("ROCKETGIT_REPO_PATH");
36 39
37 40 rg_log("Start " . rg_array2string($a)); rg_log("Start " . rg_array2string($a));
38 41 rg_log("_SERVER: " . rg_array2string($_SERVER)); rg_log("_SERVER: " . rg_array2string($_SERVER));
 
... ... if (strncmp($a['refname'], "refs/tags/", 10) == 0) {
66 69 rg_git_fatal("Unknown refname type provided [" . $a['refname'] . "]"); rg_git_fatal("Unknown refname type provided [" . $a['refname'] . "]");
67 70 } }
68 71
69 @file_put_contents($repo_path . "/rg/hook-update",
70 "repo: " . $repo . " ($repo_path)"
72 @file_put_contents($a['repo_path'] . "/rg/hook-update",
73 "repo: " . $a['repo_path']
71 74 . "\nat: " . sprintf("%u", $_start) . "\nat: " . sprintf("%u", $_start)
72 . "\nuid: " . $uid
73 . "\npara: $refname $old_rev $new_rev"
75 . "\nuid: " . $a['uid']
76 . "\npara: " . $a['refname'] . " " . $a['old_rev'] . " " . $a['new_rev']
74 77 . "\nProfiling:\n" . rg_prof_text() . "\nProfiling:\n" . rg_prof_text()
75 78 . "\n_SERVER: " . rg_array2string($_SERVER)); . "\n_SERVER: " . rg_array2string($_SERVER));
76 79
File inc/prof.inc.php changed (mode: 100644) (index 7d8cb37..08b87ca)
... ... function rg_prof_text()
136 136 { {
137 137 global $rg_prof_main; global $rg_prof_main;
138 138
139 $ret = "";
140
139 141 // get all possible variables // get all possible variables
140 142 $vars = array(); $vars = array();
141 143 foreach ($rg_prof_main as $label => $per_label) foreach ($rg_prof_main as $label => $per_label)
File inc/struct.inc.php changed (mode: 100644) (index bb670b8..60e8bfb)
... ... function rg_sql_struct_update_needed($db)
247 247 rg_log("sql_struct_update_needed:"); rg_log("sql_struct_update_needed:");
248 248
249 249 $old = rg_state_get($db, "schema_version"); $old = rg_state_get($db, "schema_version");
250 if ($old === FALSE) {
251 //TODO: error rg_log("\tDEBUG: schema is up to date!");
252 return FALSE;
253 }
254
250 255 if (empty($old)) if (empty($old))
251 256 $old = 0; $old = 0;
252 257
File inc/util.inc.php changed (mode: 100644) (index 7b95106..9bdf0f9)
... ... function rg_replace_conditionals_block($block, &$stack)
403 403 //rg_log("cond is " . ($cond ? "TRUE" : "FALSE")); //rg_log("cond is " . ($cond ? "TRUE" : "FALSE"));
404 404
405 405 // First, try to match a start of 'if' // First, try to match a start of 'if'
406 $match1 = "@@if\s*\((.*?)\s*==\s*(.*?)\)\s*?{{";
406 $match1 = "@@if\s*\((.*?)\)\s*?{{";
407 407 $match2 = "{{"; $match2 = "{{";
408 408 $match3 = "}}"; $match3 = "}}";
409 409 $search = $match1 . '|' . $match2 . '|' . $match3; $search = $match1 . '|' . $match2 . '|' . $match3;
 
... ... function rg_replace_conditionals_block($block, &$stack)
412 412 if ($r === FALSE) if ($r === FALSE)
413 413 return FALSE; return FALSE;
414 414 if ($r === 1) { if ($r === 1) {
415 //rg_log("matches: " . rg_array2string($matches));
415 rg_log("matches: " . rg_array2string($matches));
416 416
417 417 $ret = ""; $ret = "";
418 418 if ($cond) if ($cond)
419 419 $ret = $matches[1]; $ret = $matches[1];
420 420
421 $rest = $matches[5];
421 $rest = $matches[4];
422 422 if (strcmp($matches[2], "}}") == 0) { if (strcmp($matches[2], "}}") == 0) {
423 423 // We pop from stack only at }} and not at {{ // We pop from stack only at }} and not at {{
424 424 //rg_log("}}: Pop the stack!"); //rg_log("}}: Pop the stack!");
 
... ... function rg_replace_conditionals_block($block, &$stack)
426 426 } else if (strcmp($matches[2], "{{") == 0) { } else if (strcmp($matches[2], "{{") == 0) {
427 427 //rg_log("{{"); //rg_log("{{");
428 428 } else { } else {
429 $left = trim($matches[3]);
430 $right = trim($matches[4]);
431 //rg_log("if left=[$left] right=[$right]");
432 $new_cond = strcmp($left, $right) == 0 ? TRUE : FALSE;
429 rg_log("cond=" . $matches[3]);
430 if (empty($matches[3])) {
431 $new_cond = FALSE;
432 } else {
433 $r = preg_match('/^(.+?)(\s*(==|!=)?\s*(.*?))?$/su',
434 $matches[3], $matches2);
435 if ($r === FALSE) {
436 rg_internal_error("Invalid condition!");
437 return FALSE;
438 }
439 rg_log("matches2: " . rg_array2string($matches2));
440 $left = trim($matches2[1]);
441 $op = trim($matches2[3]);
442 $right = trim($matches2[4]);
443 rg_log("if left=[$left] op=[$op] right=[$right]");
444 if (empty($op)) {
445 $new_cond = empty($left) ? FALSE : TRUE;
446 } else if (strcmp($op, "==") == 0) {
447 $new_cond = strcmp($left, $right) == 0 ? TRUE : FALSE;
448 } else if (strcmp($op, "!=") == 0) {
449 $new_cond = strcmp($left, $right) == 0 ? FALSE : TRUE;
450 } else {
451 rg_internal_error("Invalid operation!");
452 return FALSE;
453 }
454 }
433 455 $not_new_cond = $new_cond ? FALSE : TRUE; $not_new_cond = $new_cond ? FALSE : TRUE;
434 456
435 457 // We have to respect the outer block condition // We have to respect the outer block condition
File root/index.php changed (mode: 100644) (index 69e7116..8c3520d)
... ... $more['HTML:rg_menu'] = implode("", rg_menu($first_menu, $rg_ui, $op, $subop));
142 142 if ($rg_ui['uid'] > 0) if ($rg_ui['uid'] > 0)
143 143 $more['rg_username'] = $rg_ui['username']; $more['rg_username'] = $rg_ui['username'];
144 144 else else
145 $more['rg_username'] = "Not logged in";
145 $more['rg_username'] = "";
146 146
147 147 rg_prof_end("MAIN"); rg_prof_end("MAIN");
148 148
File root/themes/default/index.html changed (mode: 100644) (index 511e51d..7183332)
11 11 <div id="container"> <div id="container">
12 12
13 13 <div id="header"> <div id="header">
14 <div id="logo_and_user">
14 <div id="logo_and_user" style="float: right;">
15 15 <div class="logo"> <div class="logo">
16 16 <a href="/"><b>RocketGit</b></a> <a href="/"><b>RocketGit</b></a>
17 17 </div> </div>
18 18
19 @@if(@@rg_username@@){{
19 20 <div class="user"> <div class="user">
20 21 @@rg_username@@ @@rg_username@@
21 22 </div> </div>
23 }}{{}}
22 24 </div> </div>
23 25
24 26 <div id="menus"> <div id="menus">
 
34 36
35 37 <div id="footer"> <div id="footer">
36 38 <div style="float: left; padding: 5px;"> <div style="float: left; padding: 5px;">
37 <img src="@@IMG:logo/rg4.png@@" /><br />
39 <img src="@@IMG:logo/rg4.png@@" alt="RocketGit" /><br />
38 40 <b>RocketGit</b> <b>RocketGit</b>
39 41 </div> </div>
40 42
File root/themes/default/main.css changed (mode: 100644) (index 7e51383..599bd72)
... ... form input[type="submit"] {
42 42 font-weight: bold; font-weight: bold;
43 43 font-size: 11pt; font-size: 11pt;
44 44 padding: 2px 6px 2px 6px; padding: 2px 6px 2px 6px;
45 cursor: pointer; cursor: hand;
45 cursor: pointer;
46 46 border: 2px solid #DDDDDD; border: 2px solid #DDDDDD;
47 47 background-image: -moz-linear-gradient(top, #EEEEEE, #CCCCCC); background-image: -moz-linear-gradient(top, #EEEEEE, #CCCCCC);
48 48 } }
 
... ... form input[type="submit"] {
53 53 display: inline-block; display: inline-block;
54 54 } }
55 55
56 .logo { padding: 3px 0; }
56 .logo { padding: 3px 0px; }
57 57 .logo a { .logo a {
58 58 font-size: 14pt; font-size: 14pt;
59 59 text-decoration: none; text-decoration: none;
60 60 color: red; color: red;
61 61 } }
62 62
63 .user { padding 3px 0; }
63 .user { padding: 3px 0px; }
64 64
65 65 #menus { #menus {
66 66 display: inline-block; display: inline-block;
 
... ... form input[type="submit"] {
108 108 } }
109 109
110 110 #main { #main {
111 padding-top: 10px;
112 padding-left: 25px;
113 padding-right: 25px;
114 padding-bottom: 10px;
111 padding: 10px 15px;
115 112 line-height: 120%; line-height: 120%;
116 113 } }
117 114
File root/themes/default/main.html changed (mode: 100644) (index d645f9c..721ac54)
1 <br />
1 2 <h1>Welcome to RocketGit!</h1> <h1>Welcome to RocketGit!</h1>
2 3 <br /> <br />
3 4
4 5 Our target is to be the best FLOSS software for managing Git projects. Our target is to be the best FLOSS software for managing Git projects.
5 6 With your help, we will do it. Thanks!<br /> With your help, we will do it. Thanks!<br />
6 7 <br /> <br />
7 You can create an account <a href="/op/create_account">here<a/>.<br />
8 You can create an account <a href="/op/create_account">here</a>.<br />
File scripts/cron.php changed (mode: 100644) (index 5ec0184..50a58d8)
... ... if (date("H") == 0) {
60 60 if ($res2 === FALSE) { if ($res2 === FALSE) {
61 61 rg_log("Cannot run query!"); rg_log("Cannot run query!");
62 62 } else { } else {
63 @unlink($repo_path . "/rocketgit/dirty");
63 if (file_exists($repo_path . "/rocketgit/dirty"))
64 @unlink($repo_path . "/rocketgit/dirty");
64 65 rg_sql_free_result($res2); rg_sql_free_result($res2);
65 66 } }
66 67 } }
File scripts/q.php changed (mode: 100644) (index 92e7925..b5c3993)
... ... while (TRUE) {
121 121 } }
122 122 rg_sql_free_result($res); rg_sql_free_result($res);
123 123
124 sleep(10);
124 sleep(1);
125 125 } }
126 126
127 127 rg_prof_end("MAIN"); rg_prof_end("MAIN");
File scripts/remote.php changed (mode: 100644) (index 3bcac66..df1f5a6)
... ... rg_log_set_file($rg_log_dir . "/remote.log");
21 21
22 22 function fatal($str) function fatal($str)
23 23 { {
24 global $php_errormsg;
25 24 global $access_type; global $access_type;
26 25
27 26 rg_log("Sending error: " . $str); rg_log("Sending error: " . $str);
28 rg_log("php_errormsg: " . $php_errormsg);
29 27 $str2 = "RocketGit: FATAL ERROR: " . $str . "\n"; $str2 = "RocketGit: FATAL ERROR: " . $str . "\n";
30 28 if ($access_type == 2) { // git if ($access_type == 2) { // git
31 29 $str3 = "\n" . $str2; $str3 = "\n" . $str2;
 
... ... if (isset($_SERVER['SSH_CONNECTION'])) {
89 87 fclose($f); fclose($f);
90 88 $line_len = strlen($line); $line_len = strlen($line);
91 89
90 rg_log("line=[$line]");
92 91 if ($line_len < 4) if ($line_len < 4)
93 92 fatal("\tLine is too short!"); fatal("\tLine is too short!");
94 93 $len = @hexdec(substr($line, 0, 4)); $len = @hexdec(substr($line, 0, 4));
 
... ... if (isset($_SERVER['SSH_CONNECTION'])) {
99 98 $line = substr($line, 4); $line = substr($line, 4);
100 99 $v = explode("\0", $line); $v = explode("\0", $line);
101 100 $cmd_repo = trim($v[0]); $cmd_repo = trim($v[0]);
102 $host = trim(substr($v[1], 5));
101 $host = isset($v[1]) ? trim(substr($v[1], 5)) : "";
103 102
104 103 $ip = getenv("REMOTE_HOST"); $ip = getenv("REMOTE_HOST");
105 104 } }
File tests/root/themes/util/t3/c6 added (mode: 100644) (index 0000000..6f9972a)
1 @@if(a){{A}}{{B}}
File tests/root/themes/util/t3/c7 added (mode: 100644) (index 0000000..9c9083f)
1 @@if(@@AAA@@){{A}}{{B}}
File tests/util.php changed (mode: 100644) (index e78f681..972ec87)
... ... if (strcmp($r, $e) != 0) {
172 172 exit(1); exit(1);
173 173 } }
174 174
175 rg_log("test rg_template with conditional formating (empty)");
176 $data = array();
177 $r = rg_template("t3/c6", $data);
178 $r = preg_replace('/\s/', '', $r);
179 $e = "A";
180 if (strcmp($r, $e) != 0) {
181 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
182 exit(1);
183 }
184
185 rg_log("test rg_template with conditional formating (!empty)");
186 $data = array("AAA" => "");
187 $r = rg_template("t3/c7", $data);
188 $r = preg_replace('/\s/', '', $r);
189 $e = "B";
190 if (strcmp($r, $e) != 0) {
191 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
192 exit(1);
193 }
194
175 195 // test rg_copy_tree // test rg_copy_tree
176 196 $r = rg_copy_tree("tree1", "tree1.copy", 0755); $r = rg_copy_tree("tree1", "tree1.copy", 0755);
177 197 if ($r !== TRUE) { if ($r !== TRUE) {
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