diff --git a/lib/Git/Client.php b/lib/Git/Client.php index e7a4ae0..bdb5a48 100644 --- a/lib/Git/Client.php +++ b/lib/Git/Client.php @@ -13,7 +13,7 @@ class Client /** * Creates a new repository on the specified path - * + * * @param string $path Path where the new repository will be created * @return Repository Instance of Repository */ @@ -29,7 +29,7 @@ class Client /** * Opens a repository at the specified path - * + * * @param string $path Path where the repository is located * @return Repository Instance of Repository */ @@ -44,7 +44,7 @@ class Client /** * Searches for valid repositories on the specified path - * + * * @param string $path Path where repositories will be searched * @return array Found repositories, containing their name, path and description */ @@ -52,10 +52,10 @@ class Client { $repositories = $this->recurseDirectory($path); - if (!isset($repositories)) { + if (!empty($repositories)) { throw new \RuntimeException('There are no GIT repositories in ' . $path); } - + sort($repositories); return $repositories; @@ -65,6 +65,8 @@ class Client { $dir = new \DirectoryIterator($path); + $repositories = array(); + foreach ($dir as $file) { if ($file->isDot()) { continue; @@ -72,14 +74,14 @@ class Client $isBare = file_exists($file->getPathname() . '/HEAD'); $isRepository = file_exists($file->getPathname() . '/.git/HEAD'); - + if ($file->isDir() && $isRepository || $isBare) { if ($isBare) { $description = file_get_contents($file->getPathname() . '/description'); } else { $description = file_get_contents($file->getPathname() . '/.git/description'); } - + $repositories[] = array('name' => $file->getFilename(), 'path' => $file->getPathname(), 'description' => $description); continue; } @@ -94,11 +96,11 @@ class Client /** * Execute a git command on the repository being manipulated - * + * * This method will start a new process on the current machine and - * run git commands. Once the command has been run, the method will + * run git commands. Once the command has been run, the method will * return the command line output. - * + * * @param Repository $repository Repository where the command will be run * @param string $command Git command to be run * @return string Returns the command output @@ -118,7 +120,7 @@ class Client /** * Get the current Git binary path - * + * * @return string Path where the Git binary is located */ protected function getPath() @@ -128,7 +130,7 @@ class Client /** * Set the current Git binary path - * + * * @param string $path Path where the Git binary is located */ protected function setPath($path)