Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
modess committed Nov 29, 2013
2 parents 9a39bfb + 0d49ca5 commit ce9c5e8
Show file tree
Hide file tree
Showing 7 changed files with 263 additions and 199 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ phpunit.xml
composer.lock
!.gitkeep
config.php
Guardfile
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

You know those cool graphs and statistics you can get for a repository on github? The things is that (unfortunately) not all git repositories are hosted on github for various reasons. This is the tool for rendering graphs for your repository that can be hosted anywhere, and it looks great.

## Features (v0.2.0)
## Features (v0.2.1)

* Handles multiple repositories
* Handles bare repositories
* Statistics
- Total commits
- Total contributors
Expand All @@ -30,11 +31,11 @@ Start by clone this repository and setup your web server

Install dependencies using [Composer](http://getcomposer.org/), e.g. `php composer.phar install`

Clone the repositories you want to statistics and graphs for in to the **repositories** folder.
Clone the repositories you want to statistics and graphs for in to the **repositories** folder.

cd repositories
git clone <repository-url>

You can clone as many as you want to in to this folder.

> To manually set the repositories path, copy `config.example.php` to `config.php`. Then change the value of `repositoriesPath` in the config file relative to the folder where your desired git repositories are located.
Expand Down Expand Up @@ -62,8 +63,9 @@ For more screenshots visit the [project homepage](http://www.codingswag.com/git-

## Powered by

* [php-git-repo](https://github.com/ornicar/php-git-repo)
* [Gitter](https://github.com/klaussilveira/gitter)
* [Silex](https://github.com/fabpot/Silex)
* [Carbon](https://github.com/briannesbitt/Carbon)
* [Twig](https://github.com/fabpot/Twig)
* [Flat UI](https://github.com/designmodo/Flat-UI)
* [Highcharts JS](https://github.com/highslide-software/highcharts.com)
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"require": {
"silex/silex": "1.0.*@dev",
"twig/twig": "1.*",
"ornicar/php-git-repo": "dev-master",
"nesbot/carbon": "dev-master"
"nesbot/carbon": "1.6.0",
"klaussilveira/gitter": "0.2.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*@dev",
Expand Down
27 changes: 15 additions & 12 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@

$app['config'] = $config;

$repositoryList = new RepositoryList($repositoriesPath);
$app['repositories'] = $repositoryList->getRepositories();
$repositoryList = new RepositoryList($repositoriesPath);
$app['repositories'] = $repositoryList->getRepositories();
$app['repositoryList'] = new RepositoryList;

if (count($app['repositories']) == 0) {
throw new RuntimeException("No repositories found in path: $repositoriesPath", 0);
Expand All @@ -42,21 +43,23 @@


function loadRepository ($app, $path) {
$repositoryPath = $app['config']['repositoriesPath'][$path];
//trying the old-fashioned way for compatibility
if( !realpath($repositoryPath) ){
if (isset($app['config']['repositoriesPath'][$path])) {
$repositoryPath = $app['config']['repositoriesPath'][$path];
} elseif (!realpath($path)) {
$repositoryPath = $app['config']['repositoriesPath'] . '/' . $path;
}

if (!$repository = $app['repositoryList']->loadRepository($repositoryPath)) {
throw new RuntimeException('The repository path does not contain a valid git repository', 0, $e);
}

try {
$gitWrapper = new \PHPGit_Repository(__DIR__ . '/' . $repositoryPath);
$repository = new Repository($gitWrapper);
$repository->loadCommits();
$app['repository'] = $repository;
} catch (Exception $e) {
// Catch all possible errors while loading the repository, re-wrap it with a friendlier
// message and re-throw so it's caught by the error handler:
// (the original exception is chained to the new one):
throw new RuntimeException('The repository path does not contain a valid git repository', 0, $e);
throw new RuntimeException('Could not load commits from repository', 0, $e);
}

return $repository;
Expand All @@ -78,13 +81,13 @@ function loadRepository ($app, $path) {
array(
'repositories' => $app['repositories'],
'name' => $repository->getName(),
'branch' => $repository->getGitWrapper()->getCurrentBranch(),
'statsEndpoint' => $app["request"]->getBaseUrl() . "/stats/" . $path,
'branch' => $repository->gitter->getCurrentBranch(),
'statsEndpoint' => $app["request"]->getBaseUrl() . "/git-stats/" . $path,
)
);
});

$app->get('/stats/{path}', function($path) use($app) {
$app->get('/git-stats/{path}', function($path) use($app) {
$repository = loadRepository($app, $path);

return $app->json(
Expand Down
Loading

0 comments on commit ce9c5e8

Please sign in to comment.