diff --git a/config.ini-example b/config.ini-example index 5575ba1c..c78989a8 100644 --- a/config.ini-example +++ b/config.ini-example @@ -3,6 +3,7 @@ client = '/usr/bin/git' ; Your git executable path default_branch = 'master' ; Default branch when HEAD is detached repositories[] = '/home/git/repositories/' ; Path to your repositories ; If you wish to add more repositories, just add a new line +strip_dot_git = false ; Remove usual bare repo .git extension from displayed name ; WINDOWS USERS ;client = '"C:\Program Files (x86)\Git\bin\git.exe"' ; Your git executable path diff --git a/src/Application.php b/src/Application.php index fd0f1197..5f6f92d1 100644 --- a/src/Application.php +++ b/src/Application.php @@ -59,6 +59,7 @@ public function __construct(Config $config, $root = null) $config->get('git', 'hidden') : array(), 'git.default_branch' => $config->get('git', 'default_branch') ? $config->get('git', 'default_branch') : 'master', + 'git.strip_dot_git' => $config->get('git', 'strip_dot_git') )); $this->register(new ViewUtilServiceProvider()); diff --git a/src/Git/Client.php b/src/Git/Client.php index f2a22d49..801c96d0 100644 --- a/src/Git/Client.php +++ b/src/Git/Client.php @@ -9,6 +9,7 @@ class Client extends BaseClient protected $defaultBranch; protected $hidden; protected $projects; + protected $stripDotGit; public function __construct($options = null) { @@ -16,6 +17,7 @@ public function __construct($options = null) $this->setDefaultBranch($options['default_branch']); $this->setHidden($options['hidden']); $this->setProjects($options['projects']); + $this->stripDotGit = $options['strip_dot_git']; } public function getRepositoryFromName($paths, $repo) @@ -209,7 +211,11 @@ private function recurseDirectory($path, $appendPath = '') $description = null; } - $repoName = $appendPath . $file->getFilename(); + if (($file->getExtension() == 'git') and $this->stripDotGit) { + $repoName = $appendPath . pathinfo($file->getFilename(), PATHINFO_FILENAME); + } else { + $repoName = $appendPath . $file->getFilename(); + } if (is_array($this->getProjects()) && !in_array($repoName, $this->getProjects())) { continue; diff --git a/src/Provider/GitServiceProvider.php b/src/Provider/GitServiceProvider.php index 0ec03448..fbe29302 100644 --- a/src/Provider/GitServiceProvider.php +++ b/src/Provider/GitServiceProvider.php @@ -16,6 +16,7 @@ public function register(Application $app) $options['projects'] = $app['git.projects']; $options['ini.file'] = $app['ini.file']; $options['default_branch'] = $app['git.default_branch']; + $options['strip_dot_git'] = $app['git.strip_dot_git']; return new Client($options); }; diff --git a/tests/InterfaceTest.php b/tests/InterfaceTest.php index f0dac65a..991bba2c 100644 --- a/tests/InterfaceTest.php +++ b/tests/InterfaceTest.php @@ -34,6 +34,7 @@ public static function setUpBeforeClass() $options['hidden'] = array(self::$tmpdir . '/hiddenrepo'); $options['default_branch'] = 'master'; $options['ini.file'] = 'config.ini'; + $options['strip_dot_git'] = false; $options['projects'] = false; $cacheDir = self::$tmpdir . DIRECTORY_SEPARATOR . 'cache';