Exemplo n.º 1
0
/**
 * Fetch tags data, newest first.
 *
 * @param limit maximum number of tags to return
 */
function handle_tags($project, $limit = 0)
{
    global $conf;
    $tags = git_get_tags($project);
    $result = array();
    foreach ($tags as $tag) {
        $info = git_get_commit_info($project, $tag['h']);
        $result[] = array('stamp' => $info['author_utcstamp'], 'date' => strftime($conf['datetime'], $info['author_utcstamp']), 'h' => $tag['h'], 'fullname' => $tag['fullname'], 'name' => $tag['name']);
    }
    // sort tags newest first
    // aka. two more reasons to hate PHP (figuring those out is your homework:)
    usort($result, create_function('$x, $y', '$a = $x["stamp"]; $b = $y["stamp"]; return ($a == $b ? 0 : ($a > $b ? -1 : 1));'));
    // TODO optimize this some way, currently all tags are fetched when only a
    // few are shown. The problem is that without fetching the commit info
    // above, we can't sort using dates, only by tag name...
    if ($limit > 0) {
        $result = array_splice($result, 0, $limit);
    }
    return $result;
}
Exemplo n.º 2
0
 } 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 {
                 $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, $conf['geshi_line_numbers']);