Skip to content

Commit

Permalink
Invalid repository path exception
Browse files Browse the repository at this point in the history
  • Loading branch information
matteosister committed Jun 2, 2013
1 parent 8a270ab commit c6b2b80
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
8 changes: 5 additions & 3 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ todo
* git pull

1.0.0
* git blame
* blobs management
* submodules management
* remotes DONE
* better status handling with --porcelain
* tag messages and signed tags
* named exceptions

next
* git blame
* blobs management
* submodules management

30 changes: 30 additions & 0 deletions src/GitElephant/Exception/InvalidRepositoryPathException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* User: matteo
* Date: 02/06/13
* Time: 21.58
* Just for fun...
*/


namespace GitElephant\Exception;

/**
* Class InvalidRepositoryPathException
*
* @package GitElephant\Exception
*/
class InvalidRepositoryPathException extends \Exception
{
protected $messageTpl = 'The path provided (%s) is not a valid git repository path';

/**
* @param string $message repository path
* @param int $code code
* @param \Exception $previous previous
*/
public function __construct($message = "", $code = 0, \Exception $previous = null)
{
parent::__construct(sprintf($this->messageTpl, $message), $code, $previous);
}
}
2 changes: 2 additions & 0 deletions src/GitElephant/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use GitElephant\Command\FetchCommand;
use GitElephant\Command\RemoteCommand;
use GitElephant\Exception\InvalidBranchNameException;
use GitElephant\Exception\InvalidRepositoryPathException;
use GitElephant\GitBinary;
use GitElephant\Command\Caller;
use GitElephant\Objects\Remote;
Expand Down Expand Up @@ -88,6 +89,7 @@ public function __construct($repositoryPath, GitBinary $binary = null, $name = n
$binary = new GitBinary();
}
if (!is_dir($repositoryPath)) {
throw new InvalidRepositoryPathException($repositoryPath);
throw new \InvalidArgumentException(sprintf('the path "%s" is not a repository folder', $repositoryPath));
}
$this->path = $repositoryPath;
Expand Down
2 changes: 1 addition & 1 deletion tests/GitElephant/RepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testConstruct()
{
$this->assertEquals($this->getRepository()->getPath(), $this->path);

$this->setExpectedException('InvalidArgumentException');
$this->setExpectedException('GitElephant\Exception\InvalidRepositoryPathException');
$repo = new Repository('non-existent-path');

$repo = Repository::open($this->path);
Expand Down

0 comments on commit c6b2b80

Please sign in to comment.