List of commits:
Subject Hash Author Date (UTC)
Fixes for schema autoupdate 63d2a1a4f4c0498135a96f1a3d374868dc3d3535 Catalin(ux) M. BOIE 2012-03-23 04:19:09
Test CSRF token for the rights for a repo. e2d32e100f724e80ee623f191784ce429156ac39 Catalin(ux) M. BOIE 2012-03-22 03:54:37
Fixed anon push without create branch rights 3d474b7a569b16d87a426d4c3b971a50b3299894 Catalin(ux) M. BOIE 2012-03-22 03:43:06
Use rg_repos for repositories e5bda9469fddee7f201c22dfd89292830f4c342b Catalin(ux) M. BOIE 2012-03-22 03:42:06
Corrected <label> tags 7e8621e79480b8964e04de8c54f10f1a702ea1fd Catalin(ux) M. BOIE 2012-03-20 04:25:38
Fixed unit testing 31bfe5672e7d3b620d0e7b3c07ff72d84c149001 Catalin(ux) M. BOIE 2012-03-17 17:21:21
Fixed hook_update.sh unit testing 86c4079e81efc5a4a7878e91d8f4318e443961f7 Catalin(ux) M. BOIE 2012-03-16 22:32:35
Bulk updates f696473a7faee50782d3cc01e96cc85e7900b3de Catalin(ux) M. BOIE 2012-03-14 04:38:23
Style changes. 87e30b1df29b7c6efa438be1cf369192a8068655 Catalin(ux) M. BOIE 2012-02-19 22:50:22
Bulk 0923407bff68a58a0b7b034f8a6b4489ece5b237 Catalin(ux) M. BOIE 2012-02-12 22:21:44
Bulk update 30310488bca37cefeba96b52b71c9c3e72c32907 Catalin(ux) M. BOIE 2011-12-15 23:34:03
Profiling tests. afd1df2940fe440cde9b8ede988ff24c051a10d6 Catalin(ux) M. BOIE 2011-11-03 22:10:13
More bulk updates. a2a2e2545eaad61d0c675ea2afb801f207534515 Catalin(ux) M. BOIE 2011-11-03 22:09:34
Another round of bulk updates. 45bb00a88c420d439b4dd19971808722e4a70895 Catalin(ux) M. BOIE 2011-10-24 22:31:14
Bulk update. Mostly css. 04734cd7cfc4fd4ec55dad70a3490f3065027639 Catalin(ux) M. BOIE 2011-10-03 23:18:26
Added rg_exec function and converted all calls from exec to rg_exec. 097157e5886dace2b9f67ca238a1063a3baff4a0 Catalin(ux) M. BOIE 2011-09-28 03:28:49
Another round of bulk updates cb9dbb75518ab3c214167646197ca7eb0de8e4e6 Catalin(ux) M. BOIE 2011-09-26 19:22:12
Bulk updates cad0c710542dc3fb072268eba40b0abe11217fa9 Catalin(ux) M. BOIE 2011-09-21 20:25:23
Bulk changes. d5274ef5f261086a2af6bd19ac04061bb3d55584 Catalin(ux) M. BOIE 2011-09-15 20:16:46
Store the fist instalation date in 'state' table. e4ba8a9239e72e8de5eed0b3bb1f2a5f2d429105 Catalin(ux) M. BOIE 2011-08-31 16:14:44
Commit 63d2a1a4f4c0498135a96f1a3d374868dc3d3535 - Fixes for schema autoupdate
Author: Catalin(ux) M. BOIE
Author date (UTC): 2012-03-23 04:19
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2012-03-23 04:31
Parent(s): e2d32e100f724e80ee623f191784ce429156ac39
Signing key:
Tree: 01a0d1418ea7418d329e67422f507566800fb273
File Lines added Lines deleted
.gitignore 1 0
README 8 5
TODO 2 0
admin/init.php 3 6
admin/update.php 0 56
inc/sql.inc.php 8 0
inc/struct.inc.php 70 2
inc/util.inc.php 28 9
root/index.php 6 0
scripts/cron.php 4 0
scripts/q.php 4 0
scripts/remote.php 4 0
tests/Makefile 4 4
tests/hook_update_anon_nm.sh 1 0
tests/keys.php 3 7
tests/repo.php 3 6
tests/state.php 10 7
tests/user.php 3 6
File .gitignore changed (mode: 100644) (index 003be79..bf1d908)
... ... cata/
8 8 *.log *.log
9 9 *.out *.out
10 10 Changelog-last Changelog-last
11 *.lock
File README changed (mode: 100644) (index 5ad3d65..ebe4e09)
24 24 # systemctl enable httpd.service # systemctl enable httpd.service
25 25 # systemctl start httpd.service # systemctl start httpd.service
26 26
27 . Install and activate xinetd (for git:// access)
28 # yum install xinetd
29 # systemctl enable xinetd.service
30 # systemctl start xinetd.service
31
27 32 . Install and configure PostgreSQL server . Install and configure PostgreSQL server
28 33 # yum install postgresql-server # yum install postgresql-server
29 34 # systemctl enable postgresql.service # systemctl enable postgresql.service
30 35 # service postgresql initdb (TAKE CARE! YOU MAY DESTROY ALL YOUR DATA!) # service postgresql initdb (TAKE CARE! YOU MAY DESTROY ALL YOUR DATA!)
31 36 # systemctl start postgresql.service # systemctl start postgresql.service
32 37
33 . Create a rocketgit user
38 . Create a rocketgit user and database
34 39 # su - postgres # su - postgres
35 40 $ createuser -d -R -S rocketgit $ createuser -d -R -S rocketgit
36
37 . Create the database
38 # su - postgres
39 41 $ createdb -O rocketgit rocketgit $ createdb -O rocketgit rocketgit
40 42
41 43 . Set correct rights in pg_ident.conf/pg_hba.conf and restart: . Set correct rights in pg_ident.conf/pg_hba.conf and restart:
 
65 67 . Special thanks to my brother that contributed brain and time to this project. . Special thanks to my brother that contributed brain and time to this project.
66 68 . Special thanks to git people for the best tool to manage sources. . Special thanks to git people for the best tool to manage sources.
67 69 . Special thanks to a lot of people that came with suggestions. . Special thanks to a lot of people that came with suggestions.
68 . Special thanks to gitosys, Gitorious and other projects from where I learned things.
70 . Special thanks to gitosys, Gitorious and other projects from where I learned
71 things.
File TODO changed (mode: 100644) (index 1812b68..a3a6878)
6 6 [ ] Check if repo_path is valid from security pov. [ ] Check if repo_path is valid from security pov.
7 7 [ ] Make available the push requests. [ ] Make available the push requests.
8 8 [ ] Add possibility to reject merge requests, to make them public, to delete etc. [ ] Add possibility to reject merge requests, to make them public, to delete etc.
9 [ ] Should init.php must create db schema or we delay for the first access?
9 10
10 11 == Normal priority == == Normal priority ==
11 12 [ ] [ ]
13 [ ] rg-repos should be split in rg_repos and rg_var_lib.
12 14 [ ] 'cop' variable is not good - I do not remember what it means! [ ] 'cop' variable is not good - I do not remember what it means!
13 15 [ ] $blocks = explode("@@left@@-=ROCKETGIT=-@@left@@", $a) - seems that \0 is replaced! [ ] $blocks = explode("@@left@@-=ROCKETGIT=-@@left@@", $a) - seems that \0 is replaced!
14 16 [ ] Changing repo name probably is not working right. [ ] Changing repo name probably is not working right.
File admin/init.php changed (mode: 100644) (index d7b5809..8af30b3)
... ... $INC = dirname(__FILE__) . "/../inc";
9 9 require_once($INC . "/util.inc.php"); require_once($INC . "/util.inc.php");
10 10 require_once($INC . "/log.inc.php"); require_once($INC . "/log.inc.php");
11 11 require_once($INC . "/sql.inc.php"); require_once($INC . "/sql.inc.php");
12 require_once($INC . "/db/struct.inc.php");
12 require_once($INC . "/struct.inc.php");
13 13 require_once($INC . "/state.inc.php"); require_once($INC . "/state.inc.php");
14 14
15 15 rg_log_set_file("init.log"); rg_log_set_file("init.log");
 
... ... if ($db === FALSE) {
20 20 exit(1); exit(1);
21 21 } }
22 22
23 $ignore_errors = FALSE;
24 $drop_tables = FALSE;
25 $old_schema_ver = 0;
26 $r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver);
23 $r = rg_sql_struct_update_if_needed($db, RG_NO_DROP_TABLES);
27 24 if ($r !== TRUE) { if ($r !== TRUE) {
28 echo "Cannot init structure (" . rg_sql_error() . ")!\n";
25 echo "Cannot init structure. Check the logs!\n";
29 26 exit(1); exit(1);
30 27 } }
31 28
File admin/update.php deleted (index 1a35625..0000000)
1 <?php
2 // This must be executed at every update
3 error_reporting(E_ALL);
4 ini_set("track_errors", "On");
5
6 require_once("/etc/rocketgit/config.php");
7
8 $INC = dirname(__FILE__) . "/../inc";
9 require_once($INC . "/util.inc.php");
10 require_once($INC . "/log.inc.php");
11 require_once($INC . "/state.inc.php");
12 require_once($INC . "/sql.inc.php");
13 require_once($INC . "/db/struct.inc.php");
14
15 rg_log_set_file($rg_log_dir . "/update.log");
16
17 echo "RocketGit: upgrading...\n";
18
19 $db = rg_sql_open($rg_sql);
20 if ($db === FALSE) {
21 echo "Internal error (" . rg_sql_error() . ")!\n";
22 exit(1);
23 }
24
25 // Get current schema version
26 $old_schema_ver = rg_state_get($db, "schema_version");
27 if (empty($old_schema_ver))
28 $old_schema_ver = 1;
29 echo "RocketGit: old_schema_ver=$old_schema_ver.\n";
30
31 if (rg_sql_begin($db) !== TRUE) {
32 echo "RocketGit: Cannot start transaction (" . rg_sql_error() . ")!\n";
33 exit(1);
34 }
35
36 $ignore_errors = FALSE;
37 $drop_tables = FALSE;
38 $r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver);
39 if ($r !== TRUE) {
40 echo "RocketGit: Cannot update schema (" . rg_sql_error() . ")!\n";
41 exit(1);
42 }
43
44 if (rg_state_set($db, "schema_version", $rg_sql_schema_ver) !== TRUE) {
45 echo "RocketGit: Cannot set schema_version"
46 . " (" . rg_state_error() . ")!\n";
47 exit(1);
48 }
49
50 if (rg_sql_commit($db) !== TRUE) {
51 echo "RocketGit: Cannot commit transaction (" . rg_sql_error() . ")!\n";
52 exit(1);
53 }
54
55 echo "RocketGit: OK! New schema version is $rg_sql_schema_ver.\n";
56 ?>
File inc/sql.inc.php changed (mode: 100644) (index 7ca0a1c..be8a396)
2 2 require_once($INC . "/log.inc.php"); require_once($INC . "/log.inc.php");
3 3 require_once($INC . "/prof.inc.php"); require_once($INC . "/prof.inc.php");
4 4
5 $rg_sql_conn = array();
6
5 7 $rg_sql_error = ""; $rg_sql_error = "";
6 8
7 9 if (!function_exists("pg_connect")) if (!function_exists("pg_connect"))
 
... ... function rg_sql_error()
30 32 function rg_sql_open($str) function rg_sql_open($str)
31 33 { {
32 34 global $rg_sql_debug; global $rg_sql_debug;
35 global $rg_sql_conn;
36
37 if (isset($rg_sql_conn[$str]))
38 return $rg_sql_conn[$str];
33 39
34 40 if ($rg_sql_debug > 0) if ($rg_sql_debug > 0)
35 41 rg_log("DB: opening [$str]..."); rg_log("DB: opening [$str]...");
 
... ... function rg_sql_open($str)
46 52 return FALSE; return FALSE;
47 53 } }
48 54
55 $rg_sql_conn[$str] = $db;
56
49 57 return $db; return $db;
50 58 } }
51 59
File inc/struct.inc.php renamed from inc/db/struct.inc.php (similarity 72%) (mode: 100644) (index 769176c..f0e7072)
1 1 <?php <?php
2 include_once($INC . "/sql.inc.php");
3 include_once($INC . "/state.inc.php");
4 include_once($INC . "/util.inc.php");
5
6 define("RG_DROP_TABLES", 1);
7 define("RG_IGNORE_ERRORS", 1 << 1);
8
2 9 $rg_sql_struct = array(); $rg_sql_struct = array();
3 10 $rg_sql_struct[1] = array(); $rg_sql_struct[1] = array();
4 11 $rg_sql_struct[1]['tables'] = array( $rg_sql_struct[1]['tables'] = array(
 
... ... $rg_sql_struct[4]['other'] = array(
100 107 . " ON merge_requests (repo_id)" . " ON merge_requests (repo_id)"
101 108 ); );
102 109
110 $rg_sql_struct[5] = array();
111 $rg_sql_struct[5]['tables'] = array(
112 "history_push" => "CREATE TABLE history_push ("
113 . "itime INT NOT NULL"
114 . ", repo_id INT NOT NULL"
115 . ", ip TEXT NOT NULL"
116 . ", refname TEXT NOT NULL"
117 . ", old_rev CHAR(40) NOT NULL"
118 . ", new_rev CHAR(40) NOT NULL"
119 . ")"
120 );
121
103 122 // This must be the last line // This must be the last line
104 123 $rg_sql_schema_ver = count($rg_sql_struct); $rg_sql_schema_ver = count($rg_sql_struct);
105 124
 
... ... $rg_sql_schema_ver = count($rg_sql_struct);
108 127 /* /*
109 128 * Generate structure * Generate structure
110 129 */ */
111 function rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver)
130 function rg_sql_struct_run($db, $flags, $old_schema_ver)
112 131 { {
113 132 global $rg_sql_struct; global $rg_sql_struct;
114 133 global $rg_sql_schema_ver; global $rg_sql_schema_ver;
115 134
116 rg_log("sql_struct_run:"
135 $ignore_errors = ($flags & RG_IGNORE_ERRORS) ? TRUE : FALSE;
136 $drop_tables = ($flags & RG_DROP_TABLES) ? TRUE : FALSE;
137
138 rg_log("sql_struct_run: flags=$flags"
117 139 . " ignore_errors=" . ($ignore_errors ? "Yes" : "No") . " ignore_errors=" . ($ignore_errors ? "Yes" : "No")
118 140 . " drop_tables=" . ($drop_tables ? "Yes" : "No") . " drop_tables=" . ($drop_tables ? "Yes" : "No")
119 141 . " old_schema_ver=$old_schema_ver..."); . " old_schema_ver=$old_schema_ver...");
 
... ... function rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver)
155 177 return TRUE; return TRUE;
156 178 } }
157 179
180 /*
181 * Update schema if needed
182 * Returns FALSE in case of error
183 */
184 function rg_sql_struct_update_if_needed($db, $flags)
185 {
186 global $rg_sql_schema_ver;
187
188 rg_log("sql_struct_update: flags=$flags");
189
190 $old = rg_state_get($db, "schema_version");
191 if (empty($old))
192 $old = 0;
193
194 rg_log("DEBUG: old=$old new=$rg_sql_schema_ver");
195 if ($old == $rg_sql_schema_ver) {
196 rg_log("DEBUG: schema is up to date!");
197 return TRUE;
198 }
199
200 // If we cannot lock, return error
201 if (rg_lock("schema_upgrade.lock") === FALSE)
202 return FALSE;
203
204 if (rg_sql_begin($db) !== TRUE)
205 return FALSE;
206
207 $r = rg_sql_struct_run($db, $flags, $old);
208 if ($r !== TRUE) {
209 rg_log("Cannot update schema (" . rg_sql_error() . ")");
210 return FALSE;
211 }
212
213 $r = rg_state_set($db, "schema_version", $rg_sql_schema_ver);
214 if ($r !== TRUE) {
215 rg_log("Cannot update schema ver (" . rg_state_error() . ")");
216 return FALSE;
217 }
218
219 if (rg_sql_commit($db) !== TRUE)
220 return FALSE;
221
222 rg_unlock("schema_upgrade.lock");
223
224 return TRUE;
225 }
158 226 ?> ?>
File inc/util.inc.php changed (mode: 100644) (index 6ed8a25..c733018)
... ... function rg_id($len)
57 57 return substr($id, 0, $len); return substr($id, 0, $len);
58 58 } }
59 59
60 $_lock = FALSE;
61 function rg_lock_or_exit($file)
60 $_lock = array();
61 function rg_lock($file)
62 62 { {
63 63 global $_lock; global $_lock;
64 64 global $rg_lock_dir; global $rg_lock_dir;
 
... ... function rg_lock_or_exit($file)
67 67 $rg_lock_dir = "/var/lib/rocketgit"; $rg_lock_dir = "/var/lib/rocketgit";
68 68
69 69 // Double locking? // Double locking?
70 if ($_lock !== FALSE)
70 if (isset($_lock[$file]))
71 71 return FALSE; return FALSE;
72 72
73 $_lock = @fopen($rg_lock_dir . "/" . $file, "w");
74 if ($_lock === FALSE)
73 $f = @fopen($rg_lock_dir . "/" . $file, "w");
74 if ($f === FALSE)
75 75 return FALSE; return FALSE;
76 76
77 if (!flock($_lock, LOCK_EX | LOCK_NB)) {
78 fclose($_lock);
79 exit(0);
77 if (!flock($f, LOCK_EX | LOCK_NB)) {
78 fclose($f);
79 return FALSE;
80 80 } }
81 81
82 fwrite($_lock, getmypid() . "\n");
82 fwrite($f, getmypid() . "\n");
83
84 $_lock[$file] = $f;
85
86 return TRUE;
87 }
88
89 function rg_lock_or_exit($file)
90 {
91 global $_lock;
92
93 if (rg_lock($file) === FALSE)
94 exit(0);
95 }
96
97 function rg_unlock($file)
98 {
99 global $_lock;
100
101 fclose($_lock[$file]);
83 102 } }
84 103
85 104 function rg_load() function rg_load()
File root/index.php changed (mode: 100644) (index a3561f2..4e209dc)
... ... if ($db === FALSE) {
88 88 die("Cannot open database!"); die("Cannot open database!");
89 89 } }
90 90
91 $r = rg_sql_struct_update_if_needed($db, RG_NO_DROP_TABLES);
92 if ($r !== TRUE) {
93 echo "Schema is not up-to-date! Try again later";
94 exit(1);
95 }
96
91 97 rg_user_login_by_sid($db, $sid, $rg_ui); rg_user_login_by_sid($db, $sid, $rg_ui);
92 98 rg_log("After login_by_sid, rg_ui=" . print_r($rg_ui, TRUE)); rg_log("After login_by_sid, rg_ui=" . print_r($rg_ui, TRUE));
93 99
File scripts/cron.php changed (mode: 100644) (index f09cba4..db495c2)
... ... if ($db === FALSE) {
27 27 exit(1); exit(1);
28 28 } }
29 29
30 $r = rg_sql_struct_update_if_needed($db, RG_NO_DROP_TABLES);
31 if ($r !== TRUE)
32 exit(1);
33
30 34 if (date("H") == 0) { if (date("H") == 0) {
31 35 rg_log("Compute repository sizes if dirty..."); rg_log("Compute repository sizes if dirty...");
32 36 // delete 'dirty' files // delete 'dirty' files
File scripts/q.php changed (mode: 100644) (index 621b544..c1bac8b)
... ... if ($db === FALSE) {
32 32 exit(1); exit(1);
33 33 } }
34 34
35 $r = rg_sql_struct_update_if_needed($db, RG_NO_DROP_TABLES);
36 if ($r !== TRUE)
37 exit(1);
38
35 39 $original_mtime = filemtime(__FILE__); $original_mtime = filemtime(__FILE__);
36 40
37 41 // Check our mtime so we can upgrade the software and this script will restart. // Check our mtime so we can upgrade the software and this script will restart.
File scripts/remote.php changed (mode: 100644) (index 4978f5f..20d22bb)
... ... $db = rg_sql_open($rg_sql);
133 133 if ($db === FALSE) if ($db === FALSE)
134 134 fatal("Internal error (db)!"); fatal("Internal error (db)!");
135 135
136 $r = rg_sql_struct_update_if_needed($db, RG_NO_DROP_TABLES);
137 if ($r !== TRUE)
138 fatal("We are in a short maintenance. Try again later.");
139
136 140 // Loading info about the repository // Loading info about the repository
137 141 $rr = array("prefix" => $prefix, "user" => $user, "repo" => $repo); $rr = array("prefix" => $prefix, "user" => $user, "repo" => $repo);
138 142 $ri = rg_repo_info($db, $rr); $ri = rg_repo_info($db, $rr);
File tests/Makefile changed (mode: 100644) (index c3a990b..b74c6b8)
1 tests := util db keys repo rights state user git hook_update hook_update_anon prof
1 tests := util db keys repo rights state user git prof hook_update hook_update_anon
2 2 .PHONY: $(tests) .PHONY: $(tests)
3 3
4 4 all: $(tests) all: $(tests)
 
... ... user:
27 27 git: git:
28 28 php git.php php git.php
29 29
30 prof:
31 php prof.php
32
30 33 hook_update: hook_update:
31 34 ./hook_update.sh ./hook_update.sh
32 35
33 36 hook_update_anon: hook_update_anon:
34 37 ./hook_update_anon.sh ./hook_update_anon.sh
35 38
36 prof:
37 php prof.php
38
39 39 .PHONY: clean .PHONY: clean
40 40 clean: clean:
41 41 @rm -f *.log @rm -f *.log
File tests/hook_update_anon_nm.sh changed (mode: 100755) (index fd706f1..35296c0)
1 1 #!/bin/bash #!/bin/bash
2 2
3 3 # Test anonymous push with a custom branch # Test anonymous push with a custom branch
4 # nm = non-master
4 5
5 6 C=`pwd` C=`pwd`
6 7 P="hook_update_anon_nm" P="hook_update_anon_nm"
File tests/keys.php changed (mode: 100644) (index 4c87573..0407357)
... ... ini_set("track_errors", "On");
5 5 $INC = "../inc"; $INC = "../inc";
6 6 require_once($INC . "/util.inc.php"); require_once($INC . "/util.inc.php");
7 7 require_once($INC . "/keys.inc.php"); require_once($INC . "/keys.inc.php");
8 require_once($INC . "/db/struct.inc.php");
8 require_once($INC . "/struct.inc.php");
9 9
10 10 rg_log_set_file("keys.log"); rg_log_set_file("keys.log");
11 11
 
... ... if ($db === FALSE) {
17 17 exit(1); exit(1);
18 18 } }
19 19
20 // needed for state table
21 $ignore_errors = FALSE;
22 $drop_tables = TRUE;
23 $old_schema_ver = 0;
24 $r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver);
25 if ($r === FALSE) {
20 $r = rg_sql_struct_update_if_needed($db, RG_DROP_TABLES);
21 if ($r !== TRUE) {
26 22 echo "Cannot create structure (" . rg_sql_error() . ")!\n"; echo "Cannot create structure (" . rg_sql_error() . ")!\n";
27 23 exit(1); exit(1);
28 24 } }
File tests/repo.php changed (mode: 100644) (index 87fd5fd..38547df)
... ... ini_set("track_errors", "On");
4 4
5 5 $INC = "../inc"; $INC = "../inc";
6 6 require_once($INC . "/repo.inc.php"); require_once($INC . "/repo.inc.php");
7 require_once($INC . "/db/struct.inc.php");
7 require_once($INC . "/struct.inc.php");
8 8
9 9 rg_log_set_file("repo.log"); rg_log_set_file("repo.log");
10 10
 
... ... if ($db === FALSE) {
85 85 exit(1); exit(1);
86 86 } }
87 87
88 $ignore_errors = TRUE;
89 $drop_tables = TRUE;
90 $old_schema_ver = 0;
91 $r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver);
92 if ($r === FALSE) {
88 $r = rg_sql_struct_update_if_needed($db, RG_DROP_TABLES|RG_IGNORE_ERRORS);
89 if ($r !== TRUE) {
93 90 rg_log("Cannot create struct (" . rg_sql_error() . ")!"); rg_log("Cannot create struct (" . rg_sql_error() . ")!");
94 91 exit(1); exit(1);
95 92 } }
File tests/state.php changed (mode: 100644) (index 86fb85e..7df990f)
... ... $INC = "../inc";
6 6 require_once($INC . "/log.inc.php"); require_once($INC . "/log.inc.php");
7 7 require_once($INC . "/sql.inc.php"); require_once($INC . "/sql.inc.php");
8 8 require_once($INC . "/state.inc.php"); require_once($INC . "/state.inc.php");
9 require_once($INC . "/db/struct.inc.php");
9 require_once($INC . "/struct.inc.php");
10 10
11 11 rg_log_set_file("state.log"); rg_log_set_file("state.log");
12 12
13 13 $rg_sql_debug = 1; $rg_sql_debug = 1;
14 $rg_lock_dir = ".";
14 15
15 16 $db = rg_sql_open("dbname=trg"); $db = rg_sql_open("dbname=trg");
16 17 if ($db === FALSE) { if ($db === FALSE) {
 
... ... if ($db === FALSE) {
18 19 exit(1); exit(1);
19 20 } }
20 21
21 // needed for state table
22 $ignore_errors = FALSE;
23 $drop_tables = TRUE;
24 $old_schema_ver = 0;
25 $r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver);
26 if ($r === FALSE) {
22 $r = rg_state_set($db, "schema_version", "0");
23 if ($r !== TRUE) {
24 echo "Cannot reset schema (" . rg_state_error() . ")!\n";
25 exit(1);
26 }
27
28 $r = rg_sql_struct_update_if_needed($db, RG_DROP_TABLES);
29 if ($r !== TRUE) {
27 30 echo "Cannot create structure (" . rg_sql_error() . ")!\n"; echo "Cannot create structure (" . rg_sql_error() . ")!\n";
28 31 exit(1); exit(1);
29 32 } }
File tests/user.php changed (mode: 100644) (index 4cf6eda..7ced4fe)
... ... ini_set("track_errors", "On");
4 4
5 5 $INC = "../inc"; $INC = "../inc";
6 6 require_once($INC . "/user.inc.php"); require_once($INC . "/user.inc.php");
7 require_once($INC . "/db/struct.inc.php");
7 require_once($INC . "/struct.inc.php");
8 8
9 9 $rg_sql_debug = 1; $rg_sql_debug = 1;
10 10
 
... ... if ($db === FALSE) {
24 24 exit(1); exit(1);
25 25 } }
26 26
27 $ignore_errors = FALSE;
28 $drop_tables = TRUE;
29 $old_schema_ver = 0;
30 $r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver);
31 if ($r === FALSE) {
27 $r = rg_sql_struct_update_if_needed($db, RG_DROP_TABLES);
28 if ($r !== TRUE) {
32 29 echo "Cannot create structure (" . rg_sql_error() . ")!\n"; echo "Cannot create structure (" . rg_sql_error() . ")!\n";
33 30 exit(1); exit(1);
34 31 } }
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://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

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