File TODO changed (mode: 100644) (index 94c2774..ad15ccd) |
1 |
1 |
== BEFORE FIRST RELEASE! == |
== BEFORE FIRST RELEASE! == |
2 |
2 |
[ ] Make available the merge requests. |
[ ] Make available the merge requests. |
3 |
|
[ ] Add possibility to reject merge requests, to make them public, to delete etc. |
|
|
3 |
|
[ ] Add possibility to reject merge requests, to apply, to delete etc. |
|
4 |
|
[ ] "Tree" is broken when not on "master" branch. |
|
5 |
|
[ ] JUNK1/JUNK2: http://rg.embedromix.ro:8000/user/catab/rocketgit/commit/afd1df2..f919c9b |
|
6 |
|
[ ] Confirmation e-mail comes from rg1. |
4 |
7 |
[ ] |
[ ] |
5 |
8 |
|
|
6 |
9 |
== Normal priority == |
== Normal priority == |
|
10 |
|
[ ] Add a @@DUMP@@ in every template, so a user will know what variables can use. |
|
11 |
|
[ ] Improve e-mails to not be considered spam. |
|
12 |
|
[ ] Statistics (number, tool etc.) for project access. |
|
13 |
|
[ ] For bugtracker use BerliOS as a starting point. |
|
14 |
|
[ ] Allow (anonymous) editing files on web and transform them in merge request. |
|
15 |
|
[ ] On the first page no search form! It is useless! |
|
16 |
|
[ ] Add stats for a repo. Some stuff is already in git.inc.php. |
|
17 |
|
[ ] Anti-spam: hide e-mail addresses! |
|
18 |
|
[ ] Check if a merge request was integrated (hm; what integrated means?!) and |
|
19 |
|
signal this in merge requests list? |
|
20 |
|
[ ] Add rg_branch_allow_chars and rg_tags_allow_chars. |
|
21 |
|
[ ] repo/tag|branch/<name> page shoul put next to the commit also the tag/branch. |
|
22 |
|
[ ] Order tags by mtime desc. |
7 |
23 |
[ ] If a user pushes an unknown repo, we may automatically create a repo! |
[ ] If a user pushes an unknown repo, we may automatically create a repo! |
8 |
24 |
[ ] Fix the "edit repo" page! |
[ ] Fix the "edit repo" page! |
9 |
25 |
[ ] rg-repos should be split in rg_repos and rg_var_lib. |
[ ] rg-repos should be split in rg_repos and rg_var_lib. |
File inc/git.inc.php changed (mode: 100644) (index 96ce32d..4aba847) |
... |
... |
function rg_git_update_ref($ref, $old, $new, $reason) |
341 |
341 |
/* |
/* |
342 |
342 |
* Returns a tree (git ls-tree) |
* Returns a tree (git ls-tree) |
343 |
343 |
*/ |
*/ |
344 |
|
function rg_git_ls_tree($tree) |
|
|
344 |
|
function rg_git_ls_tree($tree, $path) |
345 |
345 |
{ |
{ |
346 |
346 |
rg_prof_start("git_ls_tree"); |
rg_prof_start("git_ls_tree"); |
347 |
347 |
|
|
348 |
|
rg_log("rg_git_ls_tree: tree=$tree"); |
|
|
348 |
|
rg_log("rg_git_ls_tree: tree=$tree path=$path"); |
349 |
349 |
|
|
350 |
350 |
$ret = array(); |
$ret = array(); |
351 |
351 |
|
|
|
... |
... |
function rg_git_ls_tree($tree) |
355 |
355 |
$tree = " HEAD"; |
$tree = " HEAD"; |
356 |
356 |
} |
} |
357 |
357 |
|
|
358 |
|
$cmd = "git ls-tree --long" . $op . $tree; |
|
|
358 |
|
$cmd = "git ls-tree --long" . $op . $tree . " " . escapeshellcmd($path); |
359 |
359 |
$a = rg_exec($cmd); |
$a = rg_exec($cmd); |
360 |
360 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
361 |
361 |
rg_git_set_error("error on ls-tree (" . $a['errmsg'] . ")"); |
rg_git_set_error("error on ls-tree (" . $a['errmsg'] . ")"); |
|
... |
... |
function rg_git_log($max, $from, $to, $also_patch) |
498 |
498 |
{ |
{ |
499 |
499 |
rg_prof_start("git_log"); |
rg_prof_start("git_log"); |
500 |
500 |
|
|
501 |
|
rg_log("git_log: max=$max"); |
|
|
501 |
|
rg_log("git_log: from=$from to=$to max=$max"); |
502 |
502 |
|
|
503 |
503 |
$max_count = ($max == 0) ? "" : " --max-count=$max"; |
$max_count = ($max == 0) ? "" : " --max-count=$max"; |
504 |
504 |
$patches = $also_patch ? " --patch" : ""; |
$patches = $also_patch ? " --patch" : ""; |
505 |
505 |
|
|
506 |
|
if (empty($from) && empty($to)) |
|
|
506 |
|
if (empty($from) && empty($to)) { |
507 |
507 |
$from_to = ""; |
$from_to = ""; |
508 |
|
else |
|
509 |
|
$from_to = " " . $from . ".." . $to; |
|
|
508 |
|
} else { |
|
509 |
|
if (empty($from)) |
|
510 |
|
$from_to = " " . $to; |
|
511 |
|
else |
|
512 |
|
$from_to = " " . $from . ".." . $to; |
|
513 |
|
} |
510 |
514 |
|
|
511 |
515 |
$cmd = "git log" |
$cmd = "git log" |
512 |
516 |
. " --no-merges" |
. " --no-merges" |
|
... |
... |
function rg_git_update_tag($a) |
818 |
822 |
. " change an un-annotated tag."); |
. " change an un-annotated tag."); |
819 |
823 |
} |
} |
820 |
824 |
} |
} |
|
825 |
|
|
|
826 |
|
// If we do not have a namespace, we let git to update the ref. |
|
827 |
|
// Not clear when we do not have a namespace. |
|
828 |
|
if (!empty($a['namespace'])) { |
|
829 |
|
// Update the main namespace |
|
830 |
|
$r = rg_git_update_ref($a['refname'], $a['old_rev'], |
|
831 |
|
$a['new_rev'], "reason"); |
|
832 |
|
if ($r !== TRUE) { |
|
833 |
|
rg_git_fatal($a['refname'] . "\nCannot update ref (" |
|
834 |
|
. rg_git_error() . ")"); |
|
835 |
|
} |
|
836 |
|
|
|
837 |
|
// We can clean now the namespace - TODO |
|
838 |
|
} |
821 |
839 |
} |
} |
822 |
840 |
|
|
823 |
841 |
function rg_git_update_branch($a) |
function rg_git_update_branch($a) |
|
... |
... |
function rg_git_update_branch($a) |
886 |
904 |
// anonymous push - create a merge request |
// anonymous push - create a merge request |
887 |
905 |
// TODO: git may fail to update the reference after this hook; |
// TODO: git may fail to update the reference after this hook; |
888 |
906 |
// the mr code should check if the update was done. |
// the mr code should check if the update was done. |
|
907 |
|
$mr = "refs/mr/" |
|
908 |
|
. preg_replace('/refs\/heads\//', '', $a['refname']) |
|
909 |
|
. "_" . preg_replace('/rg_/', '', $a['namespace']); |
|
910 |
|
$r = rg_git_update_ref($mr, "", $a['new_rev'], "mr"); |
|
911 |
|
if ($r !== TRUE) { |
|
912 |
|
rg_log("Cannot update-ref: " . rg_git_error()); |
|
913 |
|
rg_git_fatal($a['refname'] . ": Cannot set refs/mr/." |
|
914 |
|
. " Try again later."); |
|
915 |
|
} |
889 |
916 |
$r = rg_mr_queue_add($a['repo_id'], $a['namespace'], |
$r = rg_mr_queue_add($a['repo_id'], $a['namespace'], |
890 |
917 |
$a['old_rev'], $a['new_rev'], $a['refname'], $a['ip']); |
$a['old_rev'], $a['new_rev'], $a['refname'], $a['ip']); |
891 |
918 |
if ($r !== TRUE) |
if ($r !== TRUE) |
|
... |
... |
function rg_git_update_branch($a) |
917 |
944 |
function rg_git_refs($repo_path) |
function rg_git_refs($repo_path) |
918 |
945 |
{ |
{ |
919 |
946 |
$ret = array(); |
$ret = array(); |
920 |
|
$ret['tags'] = rg_dir_load($repo_path . "/refs/tags"); |
|
921 |
|
$ret['branches'] = rg_dir_load($repo_path . "/refs/heads"); |
|
|
947 |
|
$ret['tag'] = rg_dir_load_deep($repo_path . "/refs/tags"); |
|
948 |
|
$ret['branch'] = rg_dir_load_deep($repo_path . "/refs/heads"); |
|
949 |
|
|
|
950 |
|
return $ret; |
|
951 |
|
} |
|
952 |
|
|
|
953 |
|
/* |
|
954 |
|
* Returns an array with links to branches and tags |
|
955 |
|
*/ |
|
956 |
|
function rg_git_branches_and_tags($repo_dir, $base_url, $current_ref) |
|
957 |
|
{ |
|
958 |
|
rg_log("git_branches_and_tags: repo_dir=$repo_dir base_url=$base_url" |
|
959 |
|
. " current_ref=$current_ref"); |
|
960 |
|
|
|
961 |
|
$ret = array(); |
|
962 |
|
|
|
963 |
|
$current = ltrim($current_ref, "/"); |
|
964 |
|
if (empty($current)) |
|
965 |
|
$current = "branch/master"; |
|
966 |
|
rg_log("DEBUG: current=[$current]"); |
|
967 |
|
|
|
968 |
|
$refs = rg_git_refs($repo_dir); |
|
969 |
|
foreach ($refs as $o => $list) { |
|
970 |
|
if (empty($list)) { |
|
971 |
|
$_ret['HTML:' . $o] = ""; |
|
972 |
|
continue; |
|
973 |
|
} |
|
974 |
|
|
|
975 |
|
$_t = "<div class=\"$o\">\n"; |
|
976 |
|
$_t .= "<ul>\n"; |
|
977 |
|
$_l = array(); |
|
978 |
|
foreach ($list as $name) { |
|
979 |
|
$name = htmlspecialchars($name); |
|
980 |
|
$ename = preg_replace('/\//', ',', $name); |
|
981 |
|
rg_log("DEBUG: compare with [" . $o . "/" . $ename . "]"); |
|
982 |
|
if (strcmp($current, $o . "/" . $ename) == 0) { |
|
983 |
|
$add_s = "<b>"; |
|
984 |
|
$add_e = "</b>"; |
|
985 |
|
} else { |
|
986 |
|
$add_s = ""; |
|
987 |
|
$add_e = ""; |
|
988 |
|
} |
|
989 |
|
$_l[] = "<li>" |
|
990 |
|
. "<a href=\"" . $base_url . "/source/log/$o/$ename" . "\">" |
|
991 |
|
. $add_s . $name . $add_e |
|
992 |
|
. "</a>" |
|
993 |
|
. "</li>"; |
|
994 |
|
} |
|
995 |
|
$_t .= implode("\n", $_l); |
|
996 |
|
$_t .= "</ul>\n"; |
|
997 |
|
$_t .= "</div>\n"; |
|
998 |
|
$ret['HTML:' . $o] = $_t; |
|
999 |
|
} |
|
1000 |
|
|
|
1001 |
|
return $ret; |
|
1002 |
|
} |
|
1003 |
|
|
|
1004 |
|
/* |
|
1005 |
|
* Identify branch/tag |
|
1006 |
|
* @paras: Example: tag|v1.1 or branch|stuff,branch3 |
|
1007 |
|
*/ |
|
1008 |
|
function rg_git_parse_ref(&$paras) |
|
1009 |
|
{ |
|
1010 |
|
rg_log("git_parse_ref: " . rg_array2string($paras)); |
|
1011 |
|
|
|
1012 |
|
$ret = array("ref_type" => "", |
|
1013 |
|
"ref_url" => "", |
|
1014 |
|
"ref_val" => "", |
|
1015 |
|
"ref_path" => ""); |
|
1016 |
|
|
|
1017 |
|
if (count($paras) < 2) |
|
1018 |
|
return $ret; |
|
1019 |
|
|
|
1020 |
|
if (strcmp($paras[0], "tag") == 0) { |
|
1021 |
|
$ret['ref_type'] = "tag"; |
|
1022 |
|
$ret['ref_path'] = "refs/tags/"; |
|
1023 |
|
} else if (strcmp($paras[0], "branch") == 0) { |
|
1024 |
|
$ret['ref_type'] = "branch"; |
|
1025 |
|
$ret['ref_path'] = "refs/heads/"; |
|
1026 |
|
} else { |
|
1027 |
|
return $ret; |
|
1028 |
|
} |
|
1029 |
|
|
|
1030 |
|
array_shift($paras); |
|
1031 |
|
$val = array_shift($paras); |
|
1032 |
|
$ret['ref_url'] = "/" . $ret['ref_type'] . "/" . $val; |
|
1033 |
|
|
|
1034 |
|
$val = preg_replace('/,/', '/', $val); |
|
1035 |
|
$ret['ref_val'] = $val; |
|
1036 |
|
$ret['ref_path'] .= $val; |
922 |
1037 |
|
|
923 |
1038 |
return $ret; |
return $ret; |
924 |
1039 |
} |
} |
File inc/mr.inc.php changed (mode: 100644) (index 50ea8bf..918c8d6) |
... |
... |
require_once($INC . "/sql.inc.php"); |
6 |
6 |
|
|
7 |
7 |
$rg_mr_env_q = getenv("ROCKETGIT_MR_QUEUE"); |
$rg_mr_env_q = getenv("ROCKETGIT_MR_QUEUE"); |
8 |
8 |
if (empty($rg_mr_env_q)) |
if (empty($rg_mr_env_q)) |
9 |
|
$rg_mr_queue = $rg_repos . "/q_merge_requests"; |
|
|
9 |
|
$rg_mr_queue = $rg_state_dir . "/q_merge_requests"; |
10 |
10 |
else |
else |
11 |
11 |
$rg_mr_queue = $rg_mr_env_q; |
$rg_mr_queue = $rg_mr_env_q; |
12 |
12 |
|
|
|
... |
... |
function rg_mr_queue_add($repo_id, $namespace, $old_rev, $new_rev, $refname, $ip |
63 |
63 |
/* |
/* |
64 |
64 |
* Add a merge request file to database |
* Add a merge request file to database |
65 |
65 |
*/ |
*/ |
66 |
|
function rg_mr_create($db, $repo_id, $namespace, $old_rev, $new_rev, $refname, $ip) |
|
|
66 |
|
function rg_mr_create($db, $repo_id, $namespace, $old_rev, $new_rev, $refname, |
|
67 |
|
$ip) |
67 |
68 |
{ |
{ |
68 |
69 |
rg_log("rg_mr_create: repo_id=$repo_id namespace=$namespace" |
rg_log("rg_mr_create: repo_id=$repo_id namespace=$namespace" |
69 |
70 |
. " old_rev=$old_rev new_rev=$new_rev, refname=$refname" |
. " old_rev=$old_rev new_rev=$new_rev, refname=$refname" |
|
... |
... |
function rg_mr_create($db, $repo_id, $namespace, $old_rev, $new_rev, $refname, $ |
76 |
77 |
. ", '$refname', '$old_rev', '$new_rev', 0, '$ip')"; |
. ", '$refname', '$old_rev', '$new_rev', 0, '$ip')"; |
77 |
78 |
$res = rg_sql_query($db, $sql); |
$res = rg_sql_query($db, $sql); |
78 |
79 |
if ($res === FALSE) { |
if ($res === FALSE) { |
79 |
|
rg_mr_set_error("cannot insert merge request (" . rg_sql_error() . ")"); |
|
|
80 |
|
rg_mr_set_error("cannot insert merge request" |
|
81 |
|
. " (" . rg_sql_error() . ")"); |
80 |
82 |
return FALSE; |
return FALSE; |
81 |
83 |
} |
} |
82 |
84 |
|
|
|
... |
... |
function rg_mr_queue_process($db) |
155 |
157 |
return $ret; |
return $ret; |
156 |
158 |
} |
} |
157 |
159 |
|
|
|
160 |
|
/* |
|
161 |
|
* Helper to condiment mr data |
|
162 |
|
*/ |
|
163 |
|
function rg_mr_condiment(&$row) |
|
164 |
|
{ |
|
165 |
|
$row['date_utc'] = gmdate("Y-m-d H:i", $row['itime']); |
|
166 |
|
$row['old_rev_short'] = substr($row['old_rev'], 0, 7); |
|
167 |
|
$row['new_rev_short'] = substr($row['new_rev'], 0, 7); |
|
168 |
|
} |
|
169 |
|
|
158 |
170 |
/* |
/* |
159 |
171 |
* Loads merge requests |
* Loads merge requests |
160 |
172 |
*/ |
*/ |
|
... |
... |
function rg_mr_load($db, $repo_id, $limit) |
175 |
187 |
|
|
176 |
188 |
$ret = array(); |
$ret = array(); |
177 |
189 |
while (($row = rg_sql_fetch_array($res))) { |
while (($row = rg_sql_fetch_array($res))) { |
178 |
|
// compute some fields |
|
179 |
|
$row['date_utc'] = gmdate("Y-m-d H:i", $row['itime']); |
|
180 |
|
|
|
|
190 |
|
rg_mr_condiment($row); |
181 |
191 |
$ret[] = $row; |
$ret[] = $row; |
182 |
192 |
} |
} |
183 |
193 |
rg_sql_free_result($res); |
rg_sql_free_result($res); |
|
... |
... |
function rg_mr_load($db, $repo_id, $limit) |
185 |
195 |
return $ret; |
return $ret; |
186 |
196 |
} |
} |
187 |
197 |
|
|
|
198 |
|
/* |
|
199 |
|
* Loads a merge request |
|
200 |
|
*/ |
|
201 |
|
function rg_mr_load_one($db, $repo_id, $namespace) |
|
202 |
|
{ |
|
203 |
|
rg_log("rg_mr_load_one: repo_id=$repo_id namespace=$namespace"); |
|
204 |
|
|
|
205 |
|
$sql = "SELECT * FROM merge_requests" |
|
206 |
|
. " WHERE repo_id = $repo_id" |
|
207 |
|
. " AND namespace = '$namespace'"; |
|
208 |
|
$res = rg_sql_query($db, $sql); |
|
209 |
|
if ($res === FALSE) { |
|
210 |
|
rg_mr_set_error("cannot load a merge request" |
|
211 |
|
. " (" . rg_sql_error() . ")"); |
|
212 |
|
return FALSE; |
|
213 |
|
} |
|
214 |
|
|
|
215 |
|
$row = rg_sql_fetch_array($res); |
|
216 |
|
rg_mr_condiment($row); |
|
217 |
|
|
|
218 |
|
rg_sql_free_result($res); |
|
219 |
|
|
|
220 |
|
return $row; |
|
221 |
|
} |
|
222 |
|
|
188 |
223 |
?> |
?> |
File inc/user.inc.php changed (mode: 100644) (index a4ae5ca..7107b57) |
... |
... |
function rg_user_forgot_pass_mail_prepare($db, $email) |
624 |
624 |
{ |
{ |
625 |
625 |
rg_log("user_forgot_pass_mail_prepare: email=$email"); |
rg_log("user_forgot_pass_mail_prepare: email=$email"); |
626 |
626 |
|
|
|
627 |
|
$ret = array(); |
|
628 |
|
$ret['ok'] = 0; |
|
629 |
|
$ret['exists'] = 0; |
|
630 |
|
|
627 |
631 |
$expire = time() + 24 * 3600; |
$expire = time() + 24 * 3600; |
628 |
632 |
$token = rg_id(40); |
$token = rg_id(40); |
629 |
633 |
|
|
630 |
634 |
$r = rg_user_info($db, 0, "", $email); |
$r = rg_user_info($db, 0, "", $email); |
631 |
|
if ($r['ok'] == 0) |
|
632 |
|
return FALSE; |
|
633 |
|
if ($r['exists'] == 0) |
|
634 |
|
return FALSE; |
|
|
635 |
|
if ($r['ok'] == 0) { |
|
636 |
|
rg_log("\tInternal error."); |
|
637 |
|
return $ret; |
|
638 |
|
} |
|
639 |
|
if ($r['exists'] == 0) { |
|
640 |
|
rg_log("\tUser does not exists."); |
|
641 |
|
$ret['ok'] = 1; |
|
642 |
|
return $ret; |
|
643 |
|
} |
635 |
644 |
$uid = $r['uid']; |
$uid = $r['uid']; |
636 |
645 |
|
|
637 |
646 |
// store token in database |
// store token in database |
|
... |
... |
function rg_user_forgot_pass_mail_prepare($db, $email) |
640 |
649 |
$res = rg_sql_query($db, $sql); |
$res = rg_sql_query($db, $sql); |
641 |
650 |
if ($res === FALSE) { |
if ($res === FALSE) { |
642 |
651 |
rg_user_set_error("cannot query (" . rg_sql_error() . ")"); |
rg_user_set_error("cannot query (" . rg_sql_error() . ")"); |
643 |
|
return FALSE; |
|
|
652 |
|
return $ret; |
644 |
653 |
} |
} |
645 |
654 |
rg_sql_free_result($res); |
rg_sql_free_result($res); |
646 |
655 |
|
|
647 |
|
return $token; |
|
|
656 |
|
$ret['ok'] = 1; |
|
657 |
|
$ret['exists'] = 1; |
|
658 |
|
$ret['token'] = $token; |
|
659 |
|
return $ret; |
648 |
660 |
} |
} |
649 |
661 |
|
|
650 |
662 |
/* |
/* |
|
... |
... |
function rg_user_forgot_pass_mail($db, $email) |
656 |
668 |
|
|
657 |
669 |
rg_log("user_forgot_pass_mail: email=$email"); |
rg_log("user_forgot_pass_mail: email=$email"); |
658 |
670 |
|
|
659 |
|
$forgot_token = rg_user_forgot_pass_mail_prepare($db, $email); |
|
660 |
|
if ($forgot_token === FALSE) |
|
661 |
|
return FALSE; |
|
|
671 |
|
$ret = array(); |
|
672 |
|
$ret['ok'] = 0; |
|
673 |
|
|
|
674 |
|
$r = rg_user_forgot_pass_mail_prepare($db, $email); |
|
675 |
|
if ($r['exists'] != 1) |
|
676 |
|
return $r; |
662 |
677 |
|
|
663 |
678 |
$headers = "From: $rg_admin_name <$rg_admin_email>"; |
$headers = "From: $rg_admin_name <$rg_admin_email>"; |
664 |
679 |
|
|
|
... |
... |
function rg_user_forgot_pass_mail($db, $email) |
672 |
687 |
$headers, |
$headers, |
673 |
688 |
"-f $rg_admin_email")) { |
"-f $rg_admin_email")) { |
674 |
689 |
rg_user_set_error("Cannot send mail ($php_errormsg)!"); |
rg_user_set_error("Cannot send mail ($php_errormsg)!"); |
675 |
|
return FALSE; |
|
|
690 |
|
return $ret; |
676 |
691 |
} |
} |
677 |
692 |
|
|
678 |
|
return TRUE; |
|
|
693 |
|
$ret['ok'] = 1; |
|
694 |
|
return $ret; |
679 |
695 |
} |
} |
680 |
696 |
|
|
681 |
697 |
/* |
/* |
File inc/user/repo-page.php changed (mode: 100644) (index 9ea8923..5e11581) |
... |
... |
$_more = array( |
42 |
42 |
); |
); |
43 |
43 |
|
|
44 |
44 |
$repo_dir = rg_repo_name2base($rr) . $rr['repo'] . ".git"; |
$repo_dir = rg_repo_name2base($rr) . $rr['repo'] . ".git"; |
|
45 |
|
rg_log("repo_dir=$repo_dir"); |
45 |
46 |
putenv("GIT_DIR=$repo_dir"); |
putenv("GIT_DIR=$repo_dir"); |
46 |
47 |
|
|
|
48 |
|
// default is "source" tab |
|
49 |
|
if (empty($subop)) |
|
50 |
|
$subop = "source"; |
|
51 |
|
|
47 |
52 |
if (strcmp($subop, "admin") == 0) { |
if (strcmp($subop, "admin") == 0) { |
48 |
53 |
if ($can_admin != 1) |
if ($can_admin != 1) |
49 |
54 |
rg_security_violation("User is not admin!"); |
rg_security_violation("User is not admin!"); |
50 |
55 |
|
|
51 |
56 |
include($INC . "/user/repo/admin.php"); |
include($INC . "/user/repo/admin.php"); |
52 |
57 |
$_repo_page_body .= $_admin; |
$_repo_page_body .= $_admin; |
53 |
|
} else if (strcmp($subop, "tree") == 0) { |
|
54 |
|
if (empty($paras[0])) |
|
55 |
|
$obj = ""; |
|
56 |
|
else |
|
57 |
|
$obj = rg_git_reference($paras[0]); |
|
58 |
|
|
|
59 |
|
$_tree = rg_git_ls_tree($obj); |
|
60 |
|
$_repo_page_body .= rg_template_table("repo/tree", $_tree, $_more); |
|
61 |
|
} else if (strcmp($subop, "blob") == 0) { |
|
62 |
|
$obj = rg_git_reference($paras[0]); |
|
63 |
|
$c = rg_git_content($obj); |
|
64 |
|
$blob = array( |
|
65 |
|
"obj" => $obj, |
|
66 |
|
"HTML:content" => rg_template_list($c) |
|
67 |
|
); |
|
68 |
|
$_repo_page_body .= rg_template("repo/blob.html", array_merge($blob, $_more)); |
|
|
58 |
|
} else if (strcmp($subop, "source") == 0) { |
|
59 |
|
$subop = array_shift($paras); |
|
60 |
|
|
|
61 |
|
$type_ref = rg_git_parse_ref($paras); |
|
62 |
|
$ref = $type_ref['ref_path']; |
|
63 |
|
$_more = array_merge($_more, $type_ref); |
|
64 |
|
|
|
65 |
|
$bt = rg_git_branches_and_tags($repo_dir, $_more['url_repo'], |
|
66 |
|
$type_ref['ref_url']); |
|
67 |
|
rg_log("DEBUG: _more: " . print_r($_more, TRUE)); |
|
68 |
|
$_more = array_merge($_more, $bt); |
|
69 |
|
|
|
70 |
|
$_repo_page_body .= rg_template("repo/source.html", $_more); |
|
71 |
|
|
|
72 |
|
rg_log("DEBUG: subop=[$subop]"); |
|
73 |
|
if (strcmp($subop, "tree") == 0) { |
|
74 |
|
if (empty($paras)) { |
|
75 |
|
$type = "tree"; |
|
76 |
|
} else { |
|
77 |
|
$type = array_shift($paras); |
|
78 |
|
} |
|
79 |
|
rg_log("DEBUG: type=[$type]"); |
|
80 |
|
|
|
81 |
|
if (strcmp($type, "tree") == 0) { |
|
82 |
|
$_tree = rg_git_ls_tree($ref, implode("/", $paras)); |
|
83 |
|
$_repo_page_body .= rg_template_table("repo/tree", $_tree, $_more); |
|
84 |
|
} else if (strcmp($type, "blob") == 0) { |
|
85 |
|
// TODO: transform path in tree |
|
86 |
|
/* |
|
87 |
|
$c = rg_git_content($obj); |
|
88 |
|
$blob = array( |
|
89 |
|
"obj" => $obj, |
|
90 |
|
"HTML:content" => rg_template_list($c) |
|
91 |
|
); |
|
92 |
|
$_repo_page_body .= rg_template("repo/blob.html", |
|
93 |
|
array_merge($blob, $_more)); |
|
94 |
|
*/ |
|
95 |
|
} |
|
96 |
|
} else { // log is default |
|
97 |
|
$log = rg_git_log(10, "", $ref, FALSE); |
|
98 |
|
if ($log === FALSE) { |
|
99 |
|
rg_log("Error generating log (" . rg_git_error() . ")!"); |
|
100 |
|
$_repo_page_body .= "Error generating log!"; |
|
101 |
|
// TODO: rg_internal_error? |
|
102 |
|
} else { |
|
103 |
|
//rg_log("DEBUG: log: " . print_r($log, TRUE)); |
|
104 |
|
$_repo_page_body .= rg_git_log_template($log, |
|
105 |
|
"repo/log", $_more); |
|
106 |
|
} |
|
107 |
|
} |
|
108 |
|
|
|
109 |
|
} else if (strcmp($subop, "issues") == 0) { |
|
110 |
|
$_repo_page_body .= rg_template("repo/issues.html", $_more); |
69 |
111 |
} else if (strcmp($subop, "stats") == 0) { |
} else if (strcmp($subop, "stats") == 0) { |
70 |
|
$_repo_page_body .= "Sorry, not yet implemented!"; |
|
|
112 |
|
$_repo_page_body .= rg_template("repo/stats.html", $_more); |
|
113 |
|
} else if (strcmp($subop, "mrs") == 0) { |
|
114 |
|
$_repo_page_body .= rg_template("repo/mrs.html", $_more); |
|
115 |
|
|
|
116 |
|
$r = rg_mr_load($db, $ri['repo_id'], 20); |
|
117 |
|
if ($r === FALSE) { |
|
118 |
|
$_repo_page_body .= "Error getting merge request list (" |
|
119 |
|
. rg_mr_error() . ")."; |
|
120 |
|
} else { |
|
121 |
|
$_repo_page_body .= rg_template_table("repo/mr/list", $r, $_more); |
|
122 |
|
} |
71 |
123 |
} else if (strcmp($subop, "mr") == 0) { |
} else if (strcmp($subop, "mr") == 0) { |
72 |
|
$r = rg_mr_load($db, $ri['repo_id'], 10); |
|
|
124 |
|
$mr = preg_replace('/[^0-9a-zA-Z_]/', '', $paras[0]); |
|
125 |
|
$r = rg_mr_load_one($db, $ri['repo_id'], $mr); |
73 |
126 |
if ($r === FALSE) { |
if ($r === FALSE) { |
74 |
|
$_repo_page_body .= "Error getting merge request list (" . rg_mr_error() . ")."; |
|
|
127 |
|
$_repo_page_body .= "Error getting merge request (" . rg_mr_error() . ")."; |
75 |
128 |
} else { |
} else { |
76 |
|
$_repo_page_body .= rg_template_table("repo/mr", $r, $_more); |
|
|
129 |
|
$_repo_page_body .= rg_template("repo/mr/page.html", $r, $_more); |
77 |
130 |
} |
} |
78 |
|
} else { // log |
|
79 |
|
if (empty($paras[0])) { |
|
80 |
|
rg_log("Show full log"); |
|
81 |
|
$log = rg_git_log(10, "", "", FALSE); |
|
82 |
|
rg_log("DEBUG: log: " . print_r($log, TRUE)); |
|
83 |
|
$_repo_page_body .= rg_git_log_template($log, "repo/log", $_more); |
|
|
131 |
|
} else if (strcmp($subop, "commit") == 0) { |
|
132 |
|
$commit = rg_git_reference($paras[0]); |
|
133 |
|
rg_log("Show diff for commit [$commit]"); |
|
134 |
|
|
|
135 |
|
if (strstr($commit, "..")) { |
|
136 |
|
$t = explode("..", $commit); |
|
137 |
|
$first = $t[0]; |
|
138 |
|
$second = $t[1]; |
84 |
139 |
} else { |
} else { |
85 |
|
$commit = rg_git_reference($paras[0]); |
|
86 |
|
rg_log("Show diff for commit [$commit]"); |
|
|
140 |
|
$first = $commit . "~1"; |
|
141 |
|
$second = $commit; |
|
142 |
|
} |
87 |
143 |
|
|
88 |
|
$log = rg_git_log(1, $commit . "~1", $commit, TRUE); |
|
89 |
|
rg_log("log: " . print_r($log, TRUE)); |
|
90 |
144 |
|
|
91 |
|
// stats |
|
92 |
|
$_repo_page_body .= rg_git_files_stats($log[0]['files'], "repo/fstat"); |
|
|
145 |
|
$log = rg_git_log(1, $first, $second, TRUE); |
|
146 |
|
rg_log("log: " . print_r($log, TRUE)); |
93 |
147 |
|
|
94 |
|
// diff |
|
95 |
|
//rg_log("patch: " . print_r($log[0]['patches'], TRUE)); |
|
96 |
|
$_repo_page_body .= rg_git_diff($log[0]['patches'], "repo/diff.html"); |
|
97 |
|
} |
|
|
148 |
|
// stats |
|
149 |
|
$_repo_page_body .= rg_git_files_stats($log[0]['files'], "repo/fstat"); |
|
150 |
|
|
|
151 |
|
// diff |
|
152 |
|
//rg_log("patch: " . print_r($log[0]['patches'], TRUE)); |
|
153 |
|
$_repo_page_body .= rg_git_diff($log[0]['patches'], "repo/diff.html"); |
98 |
154 |
} |
} |
99 |
155 |
|
|
100 |
156 |
$ri2 = $ri; |
$ri2 = $ri; |
|
... |
... |
$_repo_page_head = rg_template("repo/main.html", array_merge($ri2, $_more)); |
106 |
162 |
$_repo_page = $_repo_page_head . $_repo_page_body; |
$_repo_page = $_repo_page_head . $_repo_page_body; |
107 |
163 |
|
|
108 |
164 |
?> |
?> |
109 |
|
|
|
File inc/util.inc.php changed (mode: 100644) (index 3c8bb9d..8ebdb31) |
... |
... |
function rg_menu($a, $rg_ui) |
304 |
304 |
*/ |
*/ |
305 |
305 |
function rg_prepare_conditionals(&$data, &$what, &$values) |
function rg_prepare_conditionals(&$data, &$what, &$values) |
306 |
306 |
{ |
{ |
307 |
|
$what[] = "/@@if\(0\){{(.*)}}{{(.*)}}/U"; |
|
308 |
|
$values[] = "\\2"; |
|
|
307 |
|
$what['false'] = "/@@if\(0\){{(.*)}}{{(.*)}}/U"; |
|
308 |
|
$values['false'] = "\\2"; |
309 |
309 |
|
|
310 |
|
$what[] = "/@@if\(.*\){{(.*)}}{{(.*)}}/U"; |
|
311 |
|
$values[] = "\\1"; |
|
|
310 |
|
$what['true'] = "/@@if\(.*\){{(.*)}}{{(.*)}}/U"; |
|
311 |
|
$values['true'] = "\\1"; |
312 |
312 |
} |
} |
313 |
313 |
|
|
314 |
314 |
function rg_prepare_replace(&$data, &$what, &$values) |
function rg_prepare_replace(&$data, &$what, &$values) |
315 |
315 |
{ |
{ |
316 |
|
if (count($data) == 0) |
|
317 |
|
return; |
|
318 |
|
|
|
319 |
|
foreach ($data as $k => $v) { |
|
320 |
|
if (strncmp($k, "HTML:", 5) == 0) { |
|
321 |
|
$k = substr($k, 5); |
|
322 |
|
} else { |
|
323 |
|
$v = htmlspecialchars($v); |
|
|
316 |
|
if (!empty($data)) { |
|
317 |
|
foreach ($data as $k => $v) { |
|
318 |
|
if (strncmp($k, "HTML:", 5) == 0) { |
|
319 |
|
$k = substr($k, 5); |
|
320 |
|
} else { |
|
321 |
|
$v = htmlspecialchars($v); |
|
322 |
|
} |
|
323 |
|
$what[$k] = "/@@" . $k . "@@/U"; |
|
324 |
|
$values[$k] = $v; |
324 |
325 |
} |
} |
325 |
|
$what[] = "/@@" . $k . "@@/U"; |
|
326 |
|
$values[] = $v; |
|
327 |
326 |
} |
} |
|
327 |
|
|
|
328 |
|
$what['DUMP'] = "/@@DUMP@@/U"; |
|
329 |
|
$values['DUMP'] = print_r($data, TRUE); |
|
330 |
|
|
|
331 |
|
//rg_log("DEBUG: what: " . print_r($what, TRUE)); |
|
332 |
|
//rg_log("DEBUG: values: " . print_r($values, TRUE)); |
328 |
333 |
} |
} |
329 |
334 |
|
|
330 |
335 |
/* |
/* |
|
... |
... |
function rg_redirect($url) |
474 |
479 |
*/ |
*/ |
475 |
480 |
function rg_array2string($a) |
function rg_array2string($a) |
476 |
481 |
{ |
{ |
|
482 |
|
if (empty($a)) |
|
483 |
|
return ""; |
|
484 |
|
|
477 |
485 |
$ret = ""; |
$ret = ""; |
478 |
486 |
$add = ""; |
$add = ""; |
479 |
487 |
foreach ($a as $k => $v) { |
foreach ($a as $k => $v) { |
|
... |
... |
function rg_array2string($a) |
489 |
497 |
*/ |
*/ |
490 |
498 |
function rg_dir_load($dir) |
function rg_dir_load($dir) |
491 |
499 |
{ |
{ |
|
500 |
|
global $php_errormsg; |
|
501 |
|
|
492 |
502 |
$ret = array(); |
$ret = array(); |
493 |
|
$d = scandir($dir); |
|
|
503 |
|
$d = @scandir($dir); |
|
504 |
|
if ($d === FALSE) { |
|
505 |
|
rg_log("Cannot scan dir $dir ($php_errormsg)."); |
|
506 |
|
return $ret; |
|
507 |
|
} |
|
508 |
|
|
494 |
509 |
foreach ($d as $file) { |
foreach ($d as $file) { |
495 |
510 |
if ((strcmp($file, ".") == 0) || (strcmp($file, "..") == 0)) |
if ((strcmp($file, ".") == 0) || (strcmp($file, "..") == 0)) |
496 |
511 |
continue; |
continue; |
|
... |
... |
function rg_dir_load($dir) |
501 |
516 |
return $ret; |
return $ret; |
502 |
517 |
} |
} |
503 |
518 |
|
|
|
519 |
|
/* |
|
520 |
|
* Recursive dir load (used for references) |
|
521 |
|
*/ |
|
522 |
|
function rg_dir_load_deep($dir) |
|
523 |
|
{ |
|
524 |
|
$ret = array(); |
|
525 |
|
|
|
526 |
|
if (is_file($dir)) |
|
527 |
|
return array($dir); |
|
528 |
|
|
|
529 |
|
$d = rg_dir_load($dir); |
|
530 |
|
foreach ($d as $obj) { |
|
531 |
|
if (is_dir($dir . "/" . $obj)) { |
|
532 |
|
$c = rg_dir_load_deep($dir . "/" . $obj); |
|
533 |
|
foreach ($c as $obj2) |
|
534 |
|
$ret[] = $obj . "/" . $obj2; |
|
535 |
|
} else { |
|
536 |
|
$ret[] = $obj; |
|
537 |
|
} |
|
538 |
|
} |
|
539 |
|
|
|
540 |
|
return $ret; |
|
541 |
|
} |
|
542 |
|
|
|
543 |
|
/* |
|
544 |
|
* Copy a fs tree to another place |
|
545 |
|
*/ |
|
546 |
|
function rg_copy_tree($src, $dst, $mask) |
|
547 |
|
{ |
|
548 |
|
global $php_errormsg; |
|
549 |
|
|
|
550 |
|
if (!is_dir($dst)) { |
|
551 |
|
$r = @mkdir($dst, $mask); |
|
552 |
|
if ($r !== TRUE) { |
|
553 |
|
rg_log("ERROR: Cannot mkdir [$dst] ($php_errormsg)."); |
|
554 |
|
return FALSE; |
|
555 |
|
} |
|
556 |
|
} |
|
557 |
|
|
|
558 |
|
$d = rg_dir_load($src); |
|
559 |
|
foreach ($d as $obj) { |
|
560 |
|
if (is_dir($src . "/" . $obj)) { |
|
561 |
|
if (!is_dir($dst . "/" . $obj)) { |
|
562 |
|
$r = @mkdir($dst . "/" . $obj, $mask); |
|
563 |
|
if ($r !== TRUE) { |
|
564 |
|
rg_log("ERROR: Cannot mkdir [$dst/$obj]" |
|
565 |
|
. " ($php_errormsg)."); |
|
566 |
|
return FALSE; |
|
567 |
|
} |
|
568 |
|
} |
|
569 |
|
|
|
570 |
|
$r = rg_copy_tree($src . "/" . $obj, $dst . "/" . $obj, $mask); |
|
571 |
|
if ($r !== TRUE) |
|
572 |
|
return FALSE; |
|
573 |
|
} else { |
|
574 |
|
$r = @copy($src . "/" . $obj, $dst . "/" . $obj); |
|
575 |
|
if ($r !== TRUE) { |
|
576 |
|
rg_log("ERROR: Cannot copy file ($php_errormsg)."); |
|
577 |
|
return FALSE; |
|
578 |
|
} |
|
579 |
|
} |
|
580 |
|
} |
|
581 |
|
|
|
582 |
|
return TRUE; |
|
583 |
|
} |
|
584 |
|
|
504 |
585 |
?> |
?> |