Move 'no-fork-url' error message to top of page
[phorkie.git] / src / phorkie / Forker.php
index f293455a54010187c2c8b667f23d17c204aa5106..157cb5e3e435a6a78da4bb087469fb3de9fa2f2f 100644 (file)
@@ -32,19 +32,25 @@ 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();
-        foreach (\glob($new->gitDir . '/hooks/*') as $hookfile) {
-            \unlink($hookfile);
+            ->addArgument($new->workDir);
+        try {
+            $cmd->execute();
+        } catch (\Exception $e) {
+            //clean up, we've got no workdir otherwise
+            $new->delete();
+            throw $e;
         }
 
+        $rs = new Repository_Setup($new);
+        $rs->afterInit();
+
         return $new;
     }