Beispiel #1
0
    $template = 'commitdiff';
    $page['project'] = validate_project($_REQUEST['p']);
    $page['title'] = "{$page['project']} - Commitdiff - ViewGit";
    $hash = validate_hash($_REQUEST['h']);
    $page['commit_id'] = $hash;
    $page['subtitle'] = "Commitdiff " . substr($page['commit_id'], 0, 6);
    $info = git_get_commit_info($page['project'], $hash);
    $page['tree_id'] = $info['tree'];
    $page['message'] = $info['message'];
    $page['message_firstline'] = $info['message_firstline'];
    $page['message_full'] = $info['message_full'];
    $page['author_name'] = $info['author_name'];
    $page['author_mail'] = $info['author_mail'];
    $page['author_datetime'] = $info['author_datetime'];
    $text = fix_encoding(git_diff($page['project'], "{$hash}^", $hash));
    list($page['files'], $page['diffdata']) = format_diff($text);
    //$page['diffdata'] = format_diff($text);
} elseif ($action === 'patch') {
    $project = validate_project($_REQUEST['p']);
    $hash = validate_hash($_REQUEST['h']);
    $filename = "{$project}-" . substr($hash, 0, 7) . ".patch";
    //header("Content-Type: text/x-diff");
    header("Content-Type: application/octet-stream");
    header("Content-Transfer-Encoding: binary");
    // TODO git-style filename
    header("Content-Disposition: attachment; filename=\"{$filename}\";");
    run_git_passthru($project, "format-patch --stdout {$hash}^..{$hash}");
    die;
} elseif ($action === 'rss-log') {
    $page['project'] = validate_project($_REQUEST['p']);
    $ext_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']) . '/';
Beispiel #2
0
function print_summary($pipe = false)
{
    $tracker = array();
    if (!$pipe) {
        global $f;
        fseek($f, 0);
        while (false !== ($line = fgets($f))) {
            parse_and_add($line, $tracker);
        }
    } else {
        while (false !== ($line = fgets(STDIN))) {
            parse_and_add($line, $tracker);
        }
    }
    foreach ($tracker as $project => $diff) {
        echo "{$project}: ", format_diff($diff), "\n";
    }
}