<commit_before><?php

$app->get('{repo}/commits/{branch}', function($repo, $branch) use($app) {
    $repository = $app['git']->getRepository($app['git.repos'] . $repo);
    $pager = $app['utils']->getPager($app['request']->get('page'), $repository->getTotalCommits());
    $commits = $repository->getCommits($branch, $pager['current']);

    foreach ($commits as $commit) {
        $date = $commit->getDate();
        $date = $date->format('m/d/Y');
        $categorized[$date][] = $commit;
    }

    return $app['twig']->render('commits.twig', array(
        'baseurl'        => $app['baseurl'],
        'page'           => 'commits',
        'pager'          => $pager,
        'repo'           => $repo,
        'branch'         => $branch,
        'branches'       => $repository->getBranches(),
        'tags'           => $repository->getTags(),
        'commits'        => $categorized,
    ));
})->assert('repo', '[\w-._]+')
  ->assert('branch', '[\w-._]+')
  ->value('branch', 'master');

$app->get('{repo}/commits/{branch}/{file}/', function($repo, $branch, $file) use($app) {
    $repository = $app['git']->getRepository($app['git.repos'] . $repo);
    $pager = $app['utils']->getPager($app['request']->get('page'), $repository->getTotalCommits($file));
    $commits = $repository->getCommits($file, $pager['current']);

    foreach ($commits as $commit) {
        $date = $commit->getDate();
        $date = $date->format('m/d/Y');
        $categorized[$date][] = $commit;
    }

    return $app['twig']->render('commits.twig', array(
        'baseurl'        => $app['baseurl'],
        'page'           => 'commits',
        'pager'          => $pager,
        'repo'           => $repo,
        'branch'         => $branch,
        'branches'       => $repository->getBranches(),
        'tags'           => $repository->getTags(),
        'commits'        => $categorized,
    ));
})->assert('repo', '[\w-._]+')
  ->assert('file', '.+')
  ->assert('branch', '[\w-._]+');

$app->get('{repo}/commit/{commit}/', function($repo, $commit) use($app) {
    $repository = $app['git']->getRepository($app['git.repos'] . $repo);
    $commit = $repository->getCommit($commit);

    return $app['twig']->render('commit.twig', array(
        'baseurl'        => $app['baseurl'],
        'page'           => 'commits',
        'branch'         => 'master',
        'repo'           => $repo,
        'commit'         => $commit,
    ));
})->assert('repo', '[\w-._]+')
  ->assert('commit', '[a-f0-9]+');

$app->get('{repo}/blame/{branch}/{file}/', function($repo, $branch, $file) use($app) {
    $repository = $app['git']->getRepository($app['git.repos'] . $repo);
    $blames = $repository->getBlame($file);

    return $app['twig']->render('blame.twig', array(
        'baseurl'        => $app['baseurl'],
        'page'           => 'commits',
        'file'           => $file,
        'repo'           => $repo,
        'branch'         => $branch,
        'branches'       => $repository->getBranches(),
        'tags'           => $repository->getTags(),
        'blames'         => $blames,
    ));
})->assert('repo', '[\w-._]+')
  ->assert('file', '.+')
  ->assert('branch', '[\w-._]+');<commit_msg>Adding support for blame and commit history on bare repositories. Fixes #7, thanks @nifisher<commit_after><?php

$app->get('{repo}/commits/{branch}', function($repo, $branch) use($app) {
    $repository = $app['git']->getRepository($app['git.repos'] . $repo);
    $pager = $app['utils']->getPager($app['request']->get('page'), $repository->getTotalCommits());
    $commits = $repository->getCommits($branch, $pager['current']);

    foreach ($commits as $commit) {
        $date = $commit->getDate();
        $date = $date->format('m/d/Y');
        $categorized[$date][] = $commit;
    }

    return $app['twig']->render('commits.twig', array(
        'baseurl'        => $app['baseurl'],
        'page'           => 'commits',
        'pager'          => $pager,
        'repo'           => $repo,
        'branch'         => $branch,
        'branches'       => $repository->getBranches(),
        'tags'           => $repository->getTags(),
        'commits'        => $categorized,
    ));
})->assert('repo', '[\w-._]+')
  ->assert('branch', '[\w-._]+')
  ->value('branch', 'master');

$app->get('{repo}/commits/{branch}/{file}/', function($repo, $branch, $file) use($app) {
    $repository = $app['git']->getRepository($app['git.repos'] . $repo);
    $pager = $app['utils']->getPager($app['request']->get('page'), $repository->getTotalCommits("$branch -- $file"));
    $commits = $repository->getCommits("$branch -- $file", $pager['current']);

    foreach ($commits as $commit) {
        $date = $commit->getDate();
        $date = $date->format('m/d/Y');
        $categorized[$date][] = $commit;
    }

    return $app['twig']->render('commits.twig', array(
        'baseurl'        => $app['baseurl'],
        'page'           => 'commits',
        'pager'          => $pager,
        'repo'           => $repo,
        'branch'         => $branch,
        'branches'       => $repository->getBranches(),
        'tags'           => $repository->getTags(),
        'commits'        => $categorized,
    ));
})->assert('repo', '[\w-._]+')
  ->assert('file', '.+')
  ->assert('branch', '[\w-._]+');

$app->get('{repo}/commit/{commit}/', function($repo, $commit) use($app) {
    $repository = $app['git']->getRepository($app['git.repos'] . $repo);
    $commit = $repository->getCommit($commit);

    return $app['twig']->render('commit.twig', array(
        'baseurl'        => $app['baseurl'],
        'page'           => 'commits',
        'branch'         => 'master',
        'repo'           => $repo,
        'commit'         => $commit,
    ));
})->assert('repo', '[\w-._]+')
  ->assert('commit', '[a-f0-9]+');

$app->get('{repo}/blame/{branch}/{file}/', function($repo, $branch, $file) use($app) {
    $repository = $app['git']->getRepository($app['git.repos'] . $repo);
    $blames = $repository->getBlame("$branch -- $file");

    return $app['twig']->render('blame.twig', array(
        'baseurl'        => $app['baseurl'],
        'page'           => 'commits',
        'file'           => $file,
        'repo'           => $repo,
        'branch'         => $branch,
        'branches'       => $repository->getBranches(),
        'tags'           => $repository->getTags(),
        'blames'         => $blames,
    ));
})->assert('repo', '[\w-._]+')
  ->assert('file', '.+')
  ->assert('branch', '[\w-._]+');
{'fraction_non_alphanumeric': 0.2500764759865402, 'fraction_numerical': 0.0007647598654022637, 'mean_word_length': 2.379328165374677, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 147, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6179144', 'n_tokens_mistral': 2168, 'n_tokens_neox': 2158, 'n_words': 329}