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 77566839b41679a09859afad2a246b4d1d346c5a

Checkpoint
Author: Catalin(ux) M. BOIE
Author date (UTC): 2015-03-18 18:03
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2015-03-18 18:03
Parent(s): 489486b1331c835ea253aa267f0ae38025206c49
Signing key:
Tree: fac549deb53c6f4c6f768a5debfd774737ae3343
File Lines added Lines deleted
History.txt 1 0
TODO 19 14
duilder.conf 1 1
inc/bug.inc.php 1 0
inc/watch.inc.php 10 6
root/themes/default/main.html 10 0
root/themes/default/tos.html 8 0
root/themes/default/user/add_edit.html 3 0
samples/rg.conf 2 2
tests/http_bug.php 139 4
File History.txt changed (mode: 100644) (index 46759b7..8dd879f)
2 2
3 3 2015-01-24 - Created first official RocketGit server (rg2), thanks to Petre. 2015-01-24 - Created first official RocketGit server (rg2), thanks to Petre.
4 4 2015-03-04 - Gitorious aquired by Gitlab 2015-03-04 - Gitorious aquired by Gitlab
5 2015-03-13 - Google Code closing the gates.
File TODO changed (mode: 100644) (index 2585d29..187ac6d)
1 1 == Where I stopped last time == == Where I stopped last time ==
2 [ ] hook_update.sh is not working right.
3 [ ] phase1: Friends will need a way to register an account with a full account type.
4 Find a way to distribute this code and a way to support it in rg.
5 Probably I will allow only one plan (Friends) till they all create
6 accounts. After this, I will remove this plan?
2 [ ] Add a Terms of Services. Added, but check the link and the create
3 account form.
7 4 [ ] phase1: In mail, ar trebui adaugata si misiunea acestui proiect. [ ] phase1: In mail, ar trebui adaugata si misiunea acestui proiect.
8 5 Eventual un FAQ care sa contina si cum vom sustine acest proiect Eventual un FAQ care sa contina si cum vom sustine acest proiect
9 6 din punct de vedere financiar. Nu uita de repo-uri privat/publice. din punct de vedere financiar. Nu uita de repo-uri privat/publice.
10 7 [ ] phase1: add in mail a text like: "...any info ... reply to this e-mail" [ ] phase1: add in mail a text like: "...any info ... reply to this e-mail"
11 8 [ ] phase1: In mail trebuie sa existe un link catre site-ul principal. [ ] phase1: In mail trebuie sa existe un link catre site-ul principal.
12 [ ] Se pare ca sesiunea expira, indifierent daca e activa (apas butoane)!
13 [ ] Accessing a file with '"' inside, is not working.
14 See rocketgit.com/user/catalinux/test1/source/tree/blob/"xx\"yy"
15 9 [ ] First page: our mission, how do I install it etc.? [ ] First page: our mission, how do I install it etc.?
16 [ ] themes/default/repo/bug/note_add.html. @@note@@ is correct?
17 [ ] Seems we are stuck processing events in events.php daemon because we are
18 stuck in 'accept'. We should keep processing the events queue.
10 [ ] phase1: Probably I will define a single plan.
11
12 [ ] Se pare ca sesiunea expira, indifierent daca e activa (apas butoane)!
13 Unit test?
19 14 [ ] Check 'description_nice' and apply this everywhere. Maybe we should unset [ ] Check 'description_nice' and apply this everywhere. Maybe we should unset
20 15 'description', so people will not be tempted to use it. 'description', so people will not be tempted to use it.
21 Maybe just overwrite 'description'. And then continue with 'note'
22 unit testing.
16 Maybe just overwrite 'description'.
23 17 Planul este sa auditez peste tot dca folosesc variabile luate cu Planul este sa auditez peste tot dca folosesc variabile luate cu
24 18 rg_var_str, rg_var_re & rg_var_cookie_re. si le trintesc pe rg_var_str, rg_var_re & rg_var_cookie_re. si le trintesc pe
25 19 output fara a le trece prin template sau rg_xss_safe. output fara a le trece prin template sau rg_xss_safe.
 
27 21 Nu e OK. Trebuie doar pentru anumite cazuri: la o descriere pe pagina Nu e OK. Trebuie doar pentru anumite cazuri: la o descriere pe pagina
28 22 proiectului, e nevoie. Dar intr-un form, in textarea, nu e nevoie. proiectului, e nevoie. Dar intr-un form, in textarea, nu e nevoie.
29 23 Apoi as putea elimina description_nice. Apoi as putea elimina description_nice.
30 [ ] Test closing a bug/watch/unwatch/etc.
31 24 [ ] Security: Link-uri + xss (Ionut) [ ] Security: Link-uri + xss (Ionut)
32 25 [ ] [ ]
33 26
34 27 == BEFORE NEXT RELEASE == == BEFORE NEXT RELEASE ==
28 [ ] Add a "Stats" menu per repo: at least disk size.
29 [ ] Seems we are stuck processing events in events.php daemon because we are
30 stuck in 'accept'. We should keep processing the events queue.
31 I think this was because we did not signal the daemon. Can be closed?
32 [ ] Accessing a file with '"' inside, is not working.
33 See rocketgit.com/user/catalinux/test1/source/tree/blob/"xx\"yy"
34 [ ] Build a vm image to offer for download.
35 [ ] Add an option to specify a licence for the projects.
36 [ ] Present bugs as a git repo, so we easily add a new one by push?
37 [ ] Configuration: a number of months to keep history (see slaves).
38 [ ] vagrant install?
39 [ ] If I generated some activity on an object, do not notify myself.
35 40 [ ] Show the age of a repo/user/bug/etc. [ ] Show the age of a repo/user/bug/etc.
36 41 [ ] We should update the size of the repos only if is dirty (something pushed). [ ] We should update the size of the repos only if is dirty (something pushed).
37 42 [ ] Before custom hooks, allow enforcing a custom regex for a commit. [ ] Before custom hooks, allow enforcing a custom regex for a commit.
File duilder.conf changed (mode: 100644) (index 71bf25d..27c90d6)
1 1 PRJ="rocketgit" PRJ="rocketgit"
2 VER="0.20"
2 VER="0.21"
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 inc/bug.inc.php changed (mode: 100644) (index d6e4169..40cf306)
... ... function rg_bug_edit($db, $login_ui, $ri, $data)
500 500 } }
501 501 } }
502 502
503 // TODO: seems I do not distinguish between 'add' and 'edit'
503 504 $event = array("category" => 4100, "prio" => 200, $event = array("category" => 4100, "prio" => 200,
504 505 "repo::repo_id" => $ri['repo_id'], "repo::repo_id" => $ri['repo_id'],
505 506 "repo::name" => $ri['name'], "repo::name" => $ri['name'],
File inc/watch.inc.php changed (mode: 100644) (index 0dc1937..3817a05)
... ... function rg_watch_del($db, $type, $login_uid, $obj_id1, $obj_id2)
137 137
138 138 $ret = FALSE; $ret = FALSE;
139 139 while (1) { while (1) {
140 $params = array("login_uid" => $login_uid,
141 "obj_id1" => $obj_id1,
142 "obj_id2" => $obj_id2);
143
140 144 if (strcmp($type, "bug") == 0) { if (strcmp($type, "bug") == 0) {
141 145 $sql = "DELETE FROM watch_bug" $sql = "DELETE FROM watch_bug"
142 . " WHERE uid = $login_uid"
143 . " AND repo_id = $obj_id1"
144 . " AND bug_id = $obj_id2";
146 . " WHERE uid = @@login_uid@@"
147 . " AND repo_id = @@obj_id1@@"
148 . " AND bug_id = @@obj_id2@@";
145 149 } else if (strcmp($type, "repo") == 0) { } else if (strcmp($type, "repo") == 0) {
146 150 $sql = "DELETE FROM watch_repo" $sql = "DELETE FROM watch_repo"
147 . " WHERE uid = $login_uid"
148 . " AND repo_id = $obj_id1";
151 . " WHERE uid = @@login_uid@@"
152 . " AND repo_id = @@obj_id1@@";
149 153 } else { } else {
150 154 rg_internal_error("Invalid watch type!"); rg_internal_error("Invalid watch type!");
151 155 break; break;
152 156 } }
153 $res = rg_sql_query($db, $sql);
157 $res = rg_sql_query_params($db, $sql, $params);
154 158 if ($res === FALSE) if ($res === FALSE)
155 159 break; break;
156 160 rg_sql_free_result($res); rg_sql_free_result($res);
File root/themes/default/main.html changed (mode: 100644) (index ad4b767..aedb3e2)
5 5 Our target is to become the best FLOSS software for managing Git projects. Our target is to become the best FLOSS software for managing Git projects.
6 6 With your help, we will do it. Thanks!<br /> With your help, we will do it. Thanks!<br />
7 7 <br /> <br />
8 If you are wondering about the Enterprise Edition, the good news is that
9 is the same version with the one running here, on rocketgit.com.
10 You can run this software inside the firewall using free software.
11 <br />
12 You have access to unlimited number of repositories (both public and private).
13 <br />
14 Maybe you want to know how do we intend to sustain the business without
15 an Enterprise Edition. We will do it by offering support for our software,
16 by charging for customizations, ads (very targeted and no flash) and donations.
17 <br />
8 18 You can create an account <a href="/op/create_account">here</a>.<br /> You can create an account <a href="/op/create_account">here</a>.<br />
File root/themes/default/tos.html added (mode: 100644) (index 0000000..26379e2)
1 <h2>Terms of service v1</h2>
2 <ul>
3 <li>You must not abuse RocketGit servers.</li>
4 <li>You must not abuse others servers using RocketGit as a proxy.</li>
5 <li>You must not upload illegal content.</li>
6 <li>You must not harass other users.</li>
7 <li>You must enjoy your stay here.</li>
8 </ul>
File root/themes/default/user/add_edit.html changed (mode: 100644) (index 97701ff..423f6e9)
61 61 <input type="submit" value="@@if(@@create_mode@@ == 1){{Create}}{{Edit}}" /> <input type="submit" value="@@if(@@create_mode@@ == 1){{Create}}{{Edit}}" />
62 62 </form> </form>
63 63 </div> </div>
64
65 By creating/editing an account on this server, you accept out
66 <a href="/tos.html">Terms of service</a>.
File samples/rg.conf changed (mode: 100644) (index a600ac6..05c4c57)
17 17 #RewriteLog /var/log/httpd/rg-Rewrite.log #RewriteLog /var/log/httpd/rg-Rewrite.log
18 18 #RewriteLogLevel 3 #RewriteLogLevel 3
19 19
20 # Allow .ico, 'themes' folder and any txt file (think robots.txt)
20 # Allow .ico, 'themes' folder and robots.txt
21 21 # Also, avoid scripts that are looking for exploits # Also, avoid scripts that are looking for exploits
22 RewriteCond %{REQUEST_URI} ^/(favicon\.ico|themes/.*|robots\.txt|.*\.php.*)$
22 RewriteCond %{REQUEST_URI} ^/(favicon\.ico|themes/.*|robots\.txt|.*\.php.*|.*\.html)$
23 23 RewriteRule .* - [last] RewriteRule .* - [last]
24 24
25 25 # all rest # all rest
File tests/http_bug.php changed (mode: 100644) (index d9547d0..35aae2e)
... ... $sql = 'SELECT * FROM bugs WHERE repo_id = ' . $repo['repo_id'];
60 60 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
61 61 $row = rg_sql_fetch_array($res); $row = rg_sql_fetch_array($res);
62 62 rg_sql_free_result($res); rg_sql_free_result($res);
63 if ($row['bug_id'] != 1) {
64 rg_log("Seems the bugs do not start at 1, but " . $row['bug_id']);
65 exit(1);
66 }
63 67 if ($row['assigned_uid'] != $rg_ui2['uid']) { if ($row['assigned_uid'] != $rg_ui2['uid']) {
64 68 rg_log('assigned_uid is not ' . $rg_ui2['uid'] rg_log('assigned_uid is not ' . $rg_ui2['uid']
65 69 . ', but ' . $row['assigned_uid'] . '!'); . ', but ' . $row['assigned_uid'] . '!');
 
... ... if ($row['state'] != 1) {
69 73 rg_log('State is not 1 but ' . $row['state'] . '!'); rg_log('State is not 1 but ' . $row['state'] . '!');
70 74 exit(1); exit(1);
71 75 } }
72 $bug_id = $row['bug_id'];
73 76 $sql = 'SELECT * FROM bug_labels WHERE repo_id = ' . $repo['repo_id'] $sql = 'SELECT * FROM bug_labels WHERE repo_id = ' . $repo['repo_id']
74 . ' AND bug_id = ' . $bug_id;
77 . ' AND bug_id = 1';
75 78 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
76 79 $g = array(); $g = array();
77 80 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
 
... ... if (strcmp($p1, $p2) != 0) {
89 92
90 93 rg_log("Testing adding a note"); rg_log("Testing adding a note");
91 94
92 rg_log("Loading note form...");
95 rg_log("Loading bug/note form...");
93 96 $url = "/user/" . $rg_ui['username'] . "/" . $repo['name'] . "/bug/1"; $url = "/user/" . $rg_ui['username'] . "/" . $repo['name'] . "/bug/1";
94 97 $data = array(); $data = array();
95 98 $r = do_req($test_url . $url, $data, $headers); $r = do_req($test_url . $url, $data, $headers);
 
... ... if ($r === FALSE) {
109 112 exit(1); exit(1);
110 113 } }
111 114 $sql = 'SELECT * FROM bug_notes WHERE repo_id = ' . $repo['repo_id'] $sql = 'SELECT * FROM bug_notes WHERE repo_id = ' . $repo['repo_id']
112 . ' AND bug_id = ' . $bug_id;
115 . ' AND bug_id = 1';
113 116 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
114 117 $row = rg_sql_fetch_array($res); $row = rg_sql_fetch_array($res);
115 118 rg_sql_free_result($res); rg_sql_free_result($res);
 
... ... if ($row['uid'] != $rg_ui['uid']) {
122 125 exit(1); exit(1);
123 126 } }
124 127
128
129 // Test closing a bug
130 $token = $r['token'];
131 rg_log("Posting close bug form...");
132 $data = array('token' => $token,
133 'close_reopen' => 1,
134 'state' => 2);
135 $r = do_req($test_url . $url, $data, $headers);
136 if ($r === FALSE) {
137 rg_log('Cannot post bug request.');
138 exit(1);
139 }
140 $sql = 'SELECT * FROM bugs WHERE repo_id = ' . $repo['repo_id']
141 . ' AND bug_id = 1';
142 $res = rg_sql_query($db, $sql);
143 $row = rg_sql_fetch_array($res);
144 rg_sql_free_result($res);
145 if ($row['state'] != 2) {
146 rg_log('Seems we could not close the bug; state= [' . $row['state']);
147 exit(1);
148 }
149
150
151 // Test re-opening a bug
152 $token = $r['token'];
153 rg_log("Posting re-open bug form...");
154 $data = array('token' => $token,
155 'close_reopen' => 1,
156 'state'=> 1);
157 $r = do_req($test_url . $url, $data, $headers);
158 if ($r === FALSE) {
159 rg_log('Cannot post bug request.');
160 exit(1);
161 }
162 $sql = 'SELECT * FROM bugs WHERE repo_id = ' . $repo['repo_id']
163 . ' AND bug_id = 1';
164 $res = rg_sql_query($db, $sql);
165 $row = rg_sql_fetch_array($res);
166 rg_sql_free_result($res);
167 if ($row['state'] != 1) {
168 rg_log('Seems we could not re-open the bug;'
169 . ' state= [' . $row['state'] . ']!');
170 exit(1);
171 }
172
173
174 rg_log("Testing deleting a bug");
175 for ($i = 0; $i <= 1; $i++) {
176 $token = $r['token'];
177 rg_log("Posting delete bug form...");
178 $data = array('token' => $token,
179 'del_undel' => $i + 1);
180 $r = do_req($test_url . $url, $data, $headers);
181 if ($r === FALSE) {
182 rg_log('Cannot post bug request.');
183 exit(1);
184 }
185 $sql = 'SELECT * FROM bugs WHERE repo_id = ' . $repo['repo_id']
186 . ' AND bug_id = 1';
187 $res = rg_sql_query($db, $sql);
188 $row = rg_sql_fetch_array($res);
189 rg_sql_free_result($res);
190 if ($i == 0)
191 $test = $row['deleted'] > 0;
192 else
193 $test = $row['deleted'] == 0;
194 if (!$test) {
195 rg_log('i=' . $i . ': Seems we could not delete/undelete the bug;'
196 . ' deleted= [' . $row['deleted'] . ']!');
197 exit(1);
198 }
199 if ($row['deleted_who'] != $rg_ui['uid']) {
200 rg_log('i=' . $i . ': Seems the deleted_who was not updated;'
201 . ' deleted_who= [' . $row['deleted_who'] . ']!');
202 exit(1);
203 }
204 }
205
206
207 // Test watching a bug - we need to login as a different user
208 $r = test_login($test_url, $rg_ui2, $good_sid);
209 if ($r === FALSE)
210 exit(1);
211 $headers = array("Cookie: sid=" . $good_sid);
212
213 // We are already in the watch list because the asignee is automatically added
214 for ($i = 0; $i <= 1; $i++) {
215 rg_log("Loading bug form (i=$i)...");
216 $data = array();
217 $r = do_req($test_url . $url, $data, $headers);
218 if ($r === FALSE) {
219 rg_log('Cannot load bug form.');
220 exit(1);
221 }
222 $token = $r['token'];
223
224 rg_log("Posting (un)watch bug form...");
225 $data = array('token' => $token, 'watch' => $i, 'unwatch' => 1 - $i);
226 $r = do_req($test_url . $url, $data, $headers);
227 if ($r === FALSE) {
228 rg_log('Cannot post watch bug request.');
229 exit(1);
230 }
231 $sql = 'SELECT uid FROM watch_bug WHERE repo_id = ' . $repo['repo_id']
232 . ' AND bug_id = 1';
233 $res = rg_sql_query($db, $sql);
234 $rows = rg_sql_num_rows($res);
235 $row = array();
236 while (($r = rg_sql_fetch_array($res)))
237 $row[] = $r;
238 rg_sql_free_result($res);
239
240 if ($i == 0) { // unwatch - only rg_ui[uid] should be present
241 if (($rows != 1) || ($row[0]['uid'] != $rg_ui['uid'])) {
242 rg_log_ml('Seems we could not watch the bug; row:'
243 . print_r($row, TRUE));
244 exit(1);
245 }
246 } else {
247 $_l = array($rg_ui['uid'], $rg_ui2['uid']);
248 for ($j = 0; $j <= 1; $j++) {
249 if (!in_array($row[$j]['uid'], $_l)) {
250 rg_log('Seems I cannot unwatch a bug'
251 . ' (' . $row[$j]['uid']
252 . ' is not in the expected list)!');
253 exit(1);
254 }
255 }
256 }
257 }
258
259
125 260 rg_prof_log(); rg_prof_log();
126 261 rg_log("OK!"); rg_log("OK!");
127 262 ?> ?>
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