Fix .htaccess when used with MultiViews
[phorkie.git] / www / fork.php
index 64dceb92a860ea9ce869d1012722fb8c53c8d784..352f8bc28352dfe881272f8f2e5e5fb66fdf1a71 100644 (file)
@@ -3,10 +3,8 @@
  * Fork a repository
  */
 namespace phorkie;
+$reqWritePermissions = true;
 require_once 'www-header.php';
-if ($GLOBALS['phorkie']['auth']['secure'] > 0) {
-    include_once 'secure.php';
-}
 
 if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
     throw new Exception_Input('Forking only possible via POST');
@@ -15,22 +13,9 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
 $repo = new Repository();
 $repo->loadFromRequest();
 
-$rs = new Repositories();
-$new = $rs->createNew();
-$vc = $new->getVc();
-\rmdir($new->gitDir);//VersionControl_Git wants an existing dir, git clone not
-$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($repo->gitDir)
-    ->addArgument($new->workDir)
-    ->execute();
-\copy($repo->gitDir . '/description', $new->gitDir . '/description');
-foreach (\glob($new->gitDir . '/hooks/*') as $hookfile) {
-    \unlink($hookfile);
-}
+$forker = new Forker();
+$new    = $forker->forkLocal($repo);
 
 //FIXME: where to put fork source link?
-redirect($new->getLink('display'));
+redirect($new->getLink('display', null, true));
 ?>