diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2012-09-28 12:59:22 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2012-09-28 12:59:22 +0200 |
| commit | f259471294440e9c7463c8bf506f5967b2d67ec2 (patch) | |
| tree | 74f0735c004dc3d20e8666c4c70b802c7e626138 | |
| parent | 6bde4b82ec04ee5a1622220663bcacca2ec301d6 (diff) | |
| download | phorkie-f259471294440e9c7463c8bf506f5967b2d67ec2.tar.gz phorkie-f259471294440e9c7463c8bf506f5967b2d67ec2.zip | |
delete repository after failed clone
| -rw-r--r-- | src/phorkie/Forker.php | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/phorkie/Forker.php b/src/phorkie/Forker.php index f293455..7473f16 100644 --- a/src/phorkie/Forker.php +++ b/src/phorkie/Forker.php @@ -32,15 +32,22 @@ class Forker //VersionControl_Git wants an existing dir, git clone not \rmdir($new->gitDir); - $vc->getCommand('clone') + $cmd = $vc->getCommand('clone') //this should be setOption, but it fails with a = between name and value ->addArgument('--separate-git-dir') ->addArgument( $GLOBALS['phorkie']['cfg']['gitdir'] . '/' . $new->id . '.git' ) ->addArgument($pathOrUrl) - ->addArgument($new->workDir) - ->execute(); + ->addArgument($new->workDir); + try { + $cmd->execute(); + } catch (\Exception $e) { + //clean up, we've got no workdir otherwise + $new->delete(); + throw $e; + } + foreach (\glob($new->gitDir . '/hooks/*') as $hookfile) { \unlink($hookfile); } |
