File inc/git.inc.php changed (mode: 100644) (index 2fb12de..f178830) |
... |
... |
function rg_git_ls_tree($repo_path, $tree, $path) |
579 |
579 |
} |
} |
580 |
580 |
|
|
581 |
581 |
$a['data'] = trim($a['data']); |
$a['data'] = trim($a['data']); |
|
582 |
|
if (empty($a['data']) && !empty($path)) { |
|
583 |
|
rg_git_set_error('path does not exists'); |
|
584 |
|
break; |
|
585 |
|
} |
|
586 |
|
|
|
587 |
|
$ret = array(); |
|
588 |
|
|
582 |
589 |
if (empty($a['data'])) { |
if (empty($a['data'])) { |
583 |
|
rg_git_set_error("path does not exists"); |
|
|
590 |
|
// It seems to be an empty tree |
584 |
591 |
break; |
break; |
585 |
592 |
} |
} |
586 |
593 |
|
|
587 |
594 |
$output = explode("\n", trim($a['data'])); |
$output = explode("\n", trim($a['data'])); |
588 |
|
$ret = array(); |
|
589 |
595 |
foreach ($output as $line) { |
foreach ($output as $line) { |
590 |
596 |
//rg_log('DEBUG: processing line [' . $line . ']'); |
//rg_log('DEBUG: processing line [' . $line . ']'); |
591 |
597 |
$_y = array(); |
$_y = array(); |
|
... |
... |
function rg_git_log($path, $max, $from, $to, $also_patch) |
920 |
926 |
} |
} |
921 |
927 |
} |
} |
922 |
928 |
|
|
923 |
|
if ($also_patch) { |
|
|
929 |
|
if (!isset($parts[1])) { |
|
930 |
|
// we do nothing |
|
931 |
|
} else if ($also_patch) { |
924 |
932 |
// patches |
// patches |
925 |
933 |
$y['files'] = rg_git_diff2array($parts[1], $_extra); |
$y['files'] = rg_git_diff2array($parts[1], $_extra); |
926 |
934 |
if ($y['files'] === FALSE) |
if ($y['files'] === FALSE) |
|
... |
... |
function rg_git_log($path, $max, $from, $to, $also_patch) |
929 |
937 |
$y['vars']['lines_add'] = $_extra['lines_add']; |
$y['vars']['lines_add'] = $_extra['lines_add']; |
930 |
938 |
$y['vars']['lines_del'] = $_extra['lines_del']; |
$y['vars']['lines_del'] = $_extra['lines_del']; |
931 |
939 |
} else { |
} else { |
932 |
|
// stortstat |
|
|
940 |
|
// shortstat |
933 |
941 |
//rg_log('DEBUG parts[1]: ' . print_r($parts[1], TRUE)); |
//rg_log('DEBUG parts[1]: ' . print_r($parts[1], TRUE)); |
934 |
942 |
$t = explode(',', $parts[1]); |
$t = explode(',', $parts[1]); |
935 |
943 |
|
|
File tests/source.php added (mode: 100644) (index 0000000..103ac97) |
|
1 |
|
<?php |
|
2 |
|
error_reporting(E_ALL | E_STRICT); |
|
3 |
|
ini_set("track_errors", "On"); |
|
4 |
|
|
|
5 |
|
$INC = dirname(__FILE__) . "/../inc"; |
|
6 |
|
require_once(dirname(__FILE__) . "/config.php"); |
|
7 |
|
require_once($INC . "/init.inc.php"); |
|
8 |
|
require_once($INC . "/git.inc.php"); |
|
9 |
|
require_once("helpers.inc.php"); |
|
10 |
|
require_once("http.inc.php"); |
|
11 |
|
|
|
12 |
|
rg_log_set_file("source.log"); |
|
13 |
|
|
|
14 |
|
$rg_sql = "host=localhost user=rocketgit dbname=rocketgit connect_timeout=10"; |
|
15 |
|
$rg_no_db = TRUE; |
|
16 |
|
require_once("common.php"); |
|
17 |
|
|
|
18 |
|
$_testns = 'source'; |
|
19 |
|
$rg_cache_enable = TRUE; |
|
20 |
|
|
|
21 |
|
|
|
22 |
|
rg_test_create_user($db, $rg_ui); |
|
23 |
|
rg_log('Created user ' . $rg_ui['uid']); |
|
24 |
|
rg_test_create_repo($db, $rg_ui, $repo); |
|
25 |
|
rg_log('Created repo ' . $repo['repo_id']); |
|
26 |
|
$r = test_login($test_url, $rg_ui, $good_sid); |
|
27 |
|
if ($r === FALSE) { |
|
28 |
|
rg_log("Cannot login!"); |
|
29 |
|
exit(1); |
|
30 |
|
} |
|
31 |
|
|
|
32 |
|
|
|
33 |
|
rg_log(''); |
|
34 |
|
rg_log_enter('Uploading a key...'); |
|
35 |
|
rg_test_upload_ssh_key($db, $rg_ui, 'source', $good_sid); |
|
36 |
|
rg_log_exit(); |
|
37 |
|
|
|
38 |
|
|
|
39 |
|
rg_log(''); |
|
40 |
|
rg_log_enter('Trying to push master with an empty file...'); |
|
41 |
|
$cmsg = time() . ' commit message'; |
|
42 |
|
$remote = 'ssh://rocketgit@' . $rg_ssh_host . ':' .$rg_ssh_port |
|
43 |
|
. '/user/' . escapeshellarg($rg_ui['username']) |
|
44 |
|
. '/' . escapeshellarg($repo['name']); |
|
45 |
|
$r = rg_exec('mkdir -p temp_repos && cd temp_repos' |
|
46 |
|
. ' && rm -rf .source && mkdir .source && cd .source' |
|
47 |
|
. ' && git init && git commit --allow-empty -m "' . $cmsg . '"' |
|
48 |
|
. ' && git remote add origin ' . $remote |
|
49 |
|
. ' && export GIT_SSH_COMMAND="ssh -v -o IdentityFile=../../keys/source -o IdentitiesOnly=yes"' |
|
50 |
|
. ' && git push origin master', |
|
51 |
|
'', FALSE, FALSE); |
|
52 |
|
if ($r['ok'] != 1) { |
|
53 |
|
rg_log_ml('out: ' . $r['errmsg']); |
|
54 |
|
rg_log("Seems I cannot push master! err=$err"); |
|
55 |
|
exit(1); |
|
56 |
|
} |
|
57 |
|
$data = array(); |
|
58 |
|
$headers = array("Cookie: sid=" . $good_sid); |
|
59 |
|
rg_log('Check "log" menu...'); |
|
60 |
|
$r = do_req($test_url . '/user/' . rawurlencode($rg_ui['username']) |
|
61 |
|
. '/' . rawurlencode($repo['name']) . '/source/log', |
|
62 |
|
$data, $headers); |
|
63 |
|
if ($r === FALSE) { |
|
64 |
|
rg_log('Cannot load source/log page!'); |
|
65 |
|
exit(1); |
|
66 |
|
} |
|
67 |
|
if (!strstr($r['body'], $cmsg)) { |
|
68 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
69 |
|
rg_log('I cannot find [' . $cmsg . '] inside the body!'); |
|
70 |
|
exit(1); |
|
71 |
|
} |
|
72 |
|
rg_log('Check "Tree" menu...'); |
|
73 |
|
$r = do_req($test_url . '/user/' . rawurlencode($rg_ui['username']) |
|
74 |
|
. '/' . rawurlencode($repo['name']) . '/source/tree', |
|
75 |
|
$data, $headers); |
|
76 |
|
if ($r === FALSE) { |
|
77 |
|
rg_log('Cannot load source/tree page!'); |
|
78 |
|
exit(1); |
|
79 |
|
} |
|
80 |
|
if (!strstr($r['body'], 'Tree is empty.')) { |
|
81 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
82 |
|
rg_log('I cannot find [Tree is empty.] inside the body!'); |
|
83 |
|
exit(1); |
|
84 |
|
} |
|
85 |
|
|
|
86 |
|
rg_log_exit(); |
|
87 |
|
|
|
88 |
|
|
|
89 |
|
rg_log("OK!"); |
|
90 |
|
?> |