/** * Get one issue */ function git_get_issue($project, $hash) { $cmd = "issues show {$hash}"; $output = run_git($project, $cmd); $result = array(); foreach ($output as $line) { $title = trim(substr($line, 0, 15)); $val = trim(substr($line, 17)); if (substr($title, 0, 1) != "[") { $result[strtolower($title)] = $val; } else { $result['comments'] = array(); foreach (array_slice(explode("'", $line), 1, -1) as $comment) { if ($comment != ', ') { preg_match_all('|(.+)/(.+)/(.+)|', $comment, $out); $data = $out[3][0]; if ($data != 'issue.xml') { // comment_88ecfef5ac88156c0e49bfca907ff4a07629fae8_2008-12-30T03:06:19.937396_Is this working?.xml preg_match_all('|comment_.+_(.+)_(.+)\\.xml|', $data, $out); $d = explode('T', $out[1][0]); $result['comments'][] = array('date' => $d[0], 'time' => $d[1], 'text' => $out[2][0]); } } } } } return $result; }
function git_get_log($repo, $limit = 10, $bare = false) { $format = array('%H', '%at', '%an', '%s'); $params = implode(DELIMETER, $format); $data = run_git('log --pretty=format:"' . $params . '" -' . $limit, $repo, $bare); $result = array(); foreach ($data as $line) { $columns = explode(DELIMETER, $line); $row = array('commit' => $columns[0], 'timestamp' => $columns[1], 'author' => $columns[2], 'message' => $columns[3]); $result[] = $row; } return $result; }
/** * Find commits based on search type and string. */ function git_search_commits($project, $branch, $type, $string) { // git log -sFOO if ($type == 'change') { $cmd = 'log -S' . escapeshellarg($string); } elseif ($type == 'commit') { $cmd = 'log -i --grep=' . escapeshellarg($string); } elseif ($type == 'author') { $cmd = 'log -i --author=' . escapeshellarg($string); } elseif ($type == 'committer') { $cmd = 'log -i --committer=' . escapeshellarg($string); } else { die('Unsupported type'); } $cmd .= ' ' . $branch; $lines = run_git($project, $cmd); $result = array(); foreach ($lines as $line) { $matches = array(); if (preg_match('/^commit (.*?)$/', $line, $matches)) { $result[] = $matches[1]; } } return $result; }
$page['commit_id'] = validate_hash($_REQUEST['hb']); } else { $page['commit_id'] = 'HEAD'; } $page['subtitle'] = "Blob " . substr($page['hash'], 0, 6); $page['path'] = ''; if (isset($_REQUEST['f'])) { $page['path'] = $_REQUEST['f']; // TODO validate? } // For the header's pagenav $info = git_get_commit_info($page['project'], $page['commit_id']); $page['commit_id'] = $info['h']; $page['tree_id'] = $info['tree']; $page['pathinfo'] = git_get_path_info($page['project'], $page['commit_id'], $page['path']); $page['data'] = fix_encoding(join("\n", run_git($page['project'], "cat-file blob {$page['hash']}"))); $page['lastlog'] = git_get_commit_info($page['project'], 'HEAD', $page['path']); // GeSHi support if ($conf['geshi'] && strpos($page['path'], '.')) { $old_mask = error_reporting(E_ALL ^ E_NOTICE); require_once $conf['geshi_path']; $parts = explode('.', $page['path']); $ext = array_pop($parts); $geshi = new Geshi($page['data']); $lang = $geshi->get_language_name_from_extension($ext); if (strlen($lang) > 0) { $geshi->set_language($lang); if (is_int($conf['geshi_line_numbers'])) { if ($conf['geshi_line_numbers'] == 0) { $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); } else {