Use commit timestamps for ElasticSearch and sort on last commit time.
[phorkie.git] / www / fork.php
index f6ec95a5ac1549b6732e3cd482a555a5ddc816ba..d8a24a2ad91551edcf46ee981b58bbcf2440533e 100644 (file)
@@ -2,7 +2,8 @@
 /**
  * Fork a repository
  */
-namespace Phorkie;
+namespace phorkie;
+$reqWritePermissions = true;
 require_once 'www-header.php';
 
 if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
@@ -12,17 +13,9 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
 $repo = new Repository();
 $repo->loadFromRequest();
 
-$rs = new Repositories();
-$new = $rs->createNew();
-$new->getVc()->getCommand('clone')
-    ->addArgument($repo->repoDir)
-    ->addArgument($new->repoDir)
-    ->execute();
-\copy($repo->repoDir . '/.git/description', $new->repoDir . '/.git/description');
-foreach (glob($new->repoDir . '/.git/hooks/*') as $hookfile) {
-    unlink($hookfile);
-}
+$forker = new Forker();
+$new    = $forker->forkLocal($repo);
 
 //FIXME: where to put fork source link?
 redirect($new->getLink('display'));
-?>
\ No newline at end of file
+?>