Index forks only after their description has been set
[phorkie.git] / src / phorkie / Forker.php
index 3425a72283eefaa2f758301be6863bc8e155a178..c75cb393a1dc6dea2e524d3b4758454215bf765b 100644 (file)
@@ -7,16 +7,18 @@ class Forker
     {
         $new = $this->fork($repo->gitDir);
         \copy($repo->gitDir . '/description', $new->gitDir . '/description');
+        $this->index($new);
         return $new;
     }
 
-    public function forkRemote($url)
+    public function forkRemote($cloneUrl, $originalUrl)
     {
-        $new = $this->fork($url);
+        $new = $this->fork($cloneUrl);
         file_put_contents(
             $new->gitDir . '/description',
-            'Fork of ' . $url
+            'Fork of ' . $originalUrl
         );
+        $this->index($new);
         return $new;
     }
 
@@ -37,8 +39,15 @@ class Forker
         foreach (\glob($new->gitDir . '/hooks/*') as $hookfile) {
             \unlink($hookfile);
         }
+
         return $new;
     }
+
+    protected function index($repo)
+    {
+        $db = new Database();
+        $db->getIndexer()->addRepo($repo);
+    }
 }
 
 ?>