Permalink
Browse files

Add GitLab support.

  • Loading branch information...
Totof6942 committed Nov 9, 2015
1 parent 68f932e commit 14d49a64ccc6967372d38d7dd35c7d9a68406da6
Showing with 67 additions and 0 deletions.
  1. +37 −0 Sami/RemoteRepository/GitLabRemoteRepository.php
  2. +30 −0 examples/sf2_with_gitlab.php
@@ -0,0 +1,37 @@
<?php
/*
* This file is part of the Sami utility.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Sami\RemoteRepository;
class GitLabRemoteRepository extends AbstractRemoteRepository
{
protected $url = 'https://gitlab.com/';
public function __construct($name, $localPath, $url = '')
{
if (!empty($url)) {
$this->url = $url;
}
parent::__construct($name, $localPath);
}
public function getFileUrl($projectVersion, $relativePath, $line)
{
$url = $this->url.$this->name.'/blob/'.str_replace('\\', '/', $projectVersion.$relativePath);
if (null !== $line) {
$url .= '#L'.(int) $line;
}
return $url;
}
}
@@ -0,0 +1,30 @@
<?php
use Sami\Sami;
use Sami\RemoteRepository\GitLabRemoteRepository;
use Sami\Version\GitVersionCollection;
use Symfony\Component\Finder\Finder;
$iterator = Finder::create()
->files()
->name('*.php')
->exclude('Resources')
->exclude('Tests')
->in($dir = '/path/to/symfony/src')
;
$versions = GitVersionCollection::create($dir)
->addFromTags('v2.0.*')
->add('2.0', '2.0 branch')
->add('master', 'master branch')
;
return new Sami($iterator, array(
'theme' => 'symfony',
'versions' => $versions,
'title' => 'Symfony2 API',
'build_dir' => __DIR__.'/../build/sf2/%version%',
'cache_dir' => __DIR__.'/../cache/sf2/%version%',
'remote_repository' => new GitLabRemoteRepository('symfony/symfony', dirname($dir), 'https://gitlab.company.com/'),
'default_opened_level' => 2,
));

0 comments on commit 14d49a6

Please sign in to comment.