mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-17 11:10:57 +01:00
Merge branch 'master' into search_improve
This commit is contained in:
19
boot.php
19
boot.php
@@ -4,32 +4,17 @@ if (!isset($config)) {
|
||||
die("No configuration object provided.");
|
||||
}
|
||||
|
||||
$repositories = $config->get('git', 'repositories');
|
||||
|
||||
if (!is_array($repositories)) {
|
||||
# Convert the single item to an array - this is the internal handling
|
||||
$repositories = array($repositories);
|
||||
if (!is_writable(__DIR__ . DIRECTORY_SEPARATOR . 'cache')) {
|
||||
die(sprintf('The "%s" folder must be writable for GitList to run.', __DIR__ . DIRECTORY_SEPARATOR . 'cache'));
|
||||
}
|
||||
|
||||
$tmp_arr = array();
|
||||
foreach ($repositories as $repo) {
|
||||
$tmp = rtrim($repo, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
$tmp_arr []= $tmp;
|
||||
}
|
||||
$repositories = $tmp_arr;
|
||||
|
||||
|
||||
|
||||
// Startup and configure Silex application
|
||||
$app = new GitList\Application($config, __DIR__);
|
||||
|
||||
|
||||
// Mount the controllers
|
||||
$app->mount('', new GitList\Controller\MainController());
|
||||
$app->mount('', new GitList\Controller\BlobController());
|
||||
$app->mount('', new GitList\Controller\CommitController());
|
||||
$app->mount('', new GitList\Controller\TreeController());
|
||||
|
||||
|
||||
return $app;
|
||||
|
||||
|
||||
23
build.xml
23
build.xml
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="gitlist" default="build">
|
||||
<target name="build" depends="prepare,lint,phploc,pdepend,phpmd,phpcpd,phpunit" />
|
||||
<target name="build-package" depends="prepare-package,lint,phploc,package" />
|
||||
<target name="build" depends="prepare,lint,phploc,pdepend,phpmd,phpcpd,phpunit,phpcs" />
|
||||
<target name="build-package" depends="prepare-package,package" />
|
||||
|
||||
<target name="clean" description="Clean build artifacts">
|
||||
<delete dir="${basedir}/build"/>
|
||||
@@ -10,15 +10,18 @@
|
||||
<target name="prepare" depends="clean" description="Prepare for build">
|
||||
<mkdir dir="${basedir}/build/logs"/>
|
||||
<mkdir dir="${basedir}/build/pdepend"/>
|
||||
<copy file="config.ini-example" tofile="config.ini"/>
|
||||
<exec executable="composer" failonerror="true">
|
||||
<arg value="install" />
|
||||
<arg value="--dev" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="prepare-package" depends="clean" description="Prepare for build">
|
||||
<target name="prepare-package" description="Prepare for build">
|
||||
<delete dir="${basedir}/vendor"/>
|
||||
<exec executable="composer" failonerror="true">
|
||||
<arg value="install" />
|
||||
<arg value="--optimize-autoloader" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
@@ -75,15 +78,25 @@
|
||||
<exec executable="phpunit" failonerror="true"/>
|
||||
</target>
|
||||
|
||||
<target name="phpcs" description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
|
||||
<exec executable="phpcs" output="/dev/null">
|
||||
<arg value="--report=checkstyle" />
|
||||
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
|
||||
<arg value="--standard=PSR2" />
|
||||
<arg path="${basedir}/src" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="package" description="Package the application for distribution">
|
||||
<copy todir="${basedir}/build/gitlist/">
|
||||
<fileset dir="${basedir}" excludes="build/**, tests/**, pkg_builder/**, phpunit.xml.dist, cache.properties, .gitignore, .travis.yml, build.xml, composer.json, composer.lock, config.ini" />
|
||||
<fileset dir="${basedir}" excludes="cache/**, build/**, tests/**, pkg_builder/**, phpunit.xml.dist, cache.properties, .gitignore, .travis.yml, build.xml, composer.json, composer.lock, config.ini" />
|
||||
</copy>
|
||||
|
||||
<tar destfile="${basedir}/build/gitlist.tar.gz"
|
||||
<tar destfile="${basedir}/build/gitlist-master.tar.gz"
|
||||
basedir="${basedir}/build/"
|
||||
compression="gzip"
|
||||
longfile="gnu"
|
||||
excludes="gitlist-master.tar.gz, **/logs/**, **/pdepend/**"
|
||||
/>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
@@ -15,6 +15,8 @@ use GitList\Provider\RoutingUtilServiceProvider;
|
||||
*/
|
||||
class Application extends SilexApplication
|
||||
{
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* Constructor initialize services.
|
||||
*
|
||||
@@ -24,44 +26,35 @@ class Application extends SilexApplication
|
||||
public function __construct(Config $config, $root = null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$app = $this;
|
||||
$root = realpath($root);
|
||||
$this->path = realpath($root);
|
||||
|
||||
$this['debug'] = $config->get('app', 'debug');
|
||||
$this['filetypes'] = $config->getSection('filetypes');
|
||||
$this['cache.archives'] = $root . DIRECTORY_SEPARATOR
|
||||
. 'cache' . DIRECTORY_SEPARATOR . 'archives';
|
||||
$this['cache.archives'] = $this->getCachePath() . 'archives';
|
||||
|
||||
// Register services
|
||||
$this->register(new TwigServiceProvider(), array(
|
||||
'twig.path' => $root . DIRECTORY_SEPARATOR . 'views',
|
||||
'twig.options' => array('cache' => $root . DIRECTORY_SEPARATOR
|
||||
. 'cache' . DIRECTORY_SEPARATOR . 'views'),
|
||||
'twig.path' => $this->getViewPath(),
|
||||
'twig.options' => array('cache' => $this->getCachePath() . 'views'),
|
||||
));
|
||||
|
||||
$repositories = $config->get('git', 'repositories');
|
||||
|
||||
$cached_repos = $config->get('app', 'cached_repos');
|
||||
if (false === $cached_repos || empty($cached_repos)) {
|
||||
$cached_repos = $root . DIRECTORY_SEPARATOR . 'cache'
|
||||
. DIRECTORY_SEPARATOR . 'repos.json';
|
||||
$repositoryCache = $config->get('app', 'cached_repos');
|
||||
if (false === $repositoryCache || empty($repositoryCache)) {
|
||||
$repositoryCache = $this->getCachePath() . 'repos.json';
|
||||
}
|
||||
|
||||
$this->register(new GitServiceProvider(), array(
|
||||
'git.client' => $config->get('git', 'client'),
|
||||
'git.repos' => $repositories,
|
||||
'cache.repos' => $cached_repos,
|
||||
'cache.repos' => $repositoryCache,
|
||||
'ini.file' => "config.ini",
|
||||
'git.hidden' => $config->get('git', 'hidden') ?
|
||||
$config->get('git', 'hidden') : array(),
|
||||
'git.default_branch' => $config->get('git', 'default_branch') ? $config->get('git', 'default_branch') : 'master',
|
||||
));
|
||||
|
||||
$cached_repos = $root . DIRECTORY_SEPARATOR .
|
||||
'cache' . DIRECTORY_SEPARATOR . 'repos.json';
|
||||
|
||||
|
||||
$this->register(new ViewUtilServiceProvider());
|
||||
$this->register(new RepositoryUtilServiceProvider());
|
||||
$this->register(new UrlGeneratorServiceProvider());
|
||||
@@ -74,7 +67,6 @@ class Application extends SilexApplication
|
||||
return $twig;
|
||||
}));
|
||||
|
||||
|
||||
// Handle errors
|
||||
$this->error(function (\Exception $e, $code) use ($app) {
|
||||
if ($app['debug']) {
|
||||
@@ -86,5 +78,26 @@ class Application extends SilexApplication
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
public function setPath($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCachePath()
|
||||
{
|
||||
return $this->path . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
public function getViewPath()
|
||||
{
|
||||
return $this->path . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
|
||||
namespace GitList\Exception;
|
||||
|
||||
class BlankDataException extends \RuntimeException {}
|
||||
class BlankDataException extends \RuntimeException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
8
src/GitList/Exception/EmptyRepositoryException.php
Normal file
8
src/GitList/Exception/EmptyRepositoryException.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace GitList\Exception;
|
||||
|
||||
class EmptyRepositoryException extends \RuntimeException
|
||||
{
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace GitList\Util;
|
||||
|
||||
use Silex\Application;
|
||||
use GitList\Exception\EmptyRepositoryException;
|
||||
|
||||
class Routing
|
||||
{
|
||||
@@ -40,8 +41,6 @@ class Routing
|
||||
}
|
||||
|
||||
if ($commitish === null) {
|
||||
// DEBUG Can you have a repo with no branches? How should we handle
|
||||
// that?
|
||||
$branches = $repository->getBranches();
|
||||
|
||||
$tags = $repository->getTags();
|
||||
@@ -59,11 +58,11 @@ class Routing
|
||||
}
|
||||
}
|
||||
|
||||
$commitish = $matchedBranch;
|
||||
}
|
||||
if ($matchedBranch === null) {
|
||||
throw new EmptyRepositoryException('This repository is currently empty. There are no commits.');
|
||||
}
|
||||
|
||||
if ($commitish === null) {
|
||||
$app->abort(404, "'$branch_path' does not appear to contain a commit-ish for '$repo'.");
|
||||
$commitish = $matchedBranch;
|
||||
}
|
||||
|
||||
$commitishLength = strlen($commitish);
|
||||
@@ -72,11 +71,6 @@ class Routing
|
||||
$path = substr($path, 1);
|
||||
}
|
||||
|
||||
$commitHasPath = $repository->pathExists($commitish, $path);
|
||||
if ($commitHasPath !== true) {
|
||||
$app->abort(404, "\"$path\" does not exist in \"$commitish\".");
|
||||
}
|
||||
|
||||
return array($commitish, $path);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
|
||||
{% if files is not empty %}
|
||||
<table class="tree">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -54,6 +55,9 @@
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>This repository is empty.</p>
|
||||
{% endif %}
|
||||
{% if readme is defined and readme is not empty %}
|
||||
<div class="readme-view">
|
||||
<div class="md-header">
|
||||
|
||||
Reference in New Issue
Block a user