Fix bug #31: forked pastes cannot be remote forked
authorChristian Weiske <cweiske@cweiske.de>
Mon, 1 Oct 2012 20:40:24 +0000 (22:40 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Mon, 1 Oct 2012 20:40:24 +0000 (22:40 +0200)
ChangeLog
src/phorkie/Forker.php
src/phorkie/Repository/Post.php
src/phorkie/Repository/Setup.php [new file with mode: 0644]

index fc17753ce403c0734757e64398119980c061d732..94057fd416b8527edaf791c6f5ea36e651dc6a72 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2012-10-01  Christian Weiske  <cweiske@cweiske.de>
 
        * Fix bug #27: render .json files
+       * Fix bug #31: forked pastes cannot be remote forked
 
 2012-09-28  Christian Weiske  <cweiske@cweiske.de>
 
index 7473f1633aad1acf34b50c667618cf5b4772205a..157cb5e3e435a6a78da4bb087469fb3de9fa2f2f 100644 (file)
@@ -48,9 +48,8 @@ class Forker
             throw $e;
         }
 
-        foreach (\glob($new->gitDir . '/hooks/*') as $hookfile) {
-            \unlink($hookfile);
-        }
+        $rs = new Repository_Setup($new);
+        $rs->afterInit();
 
         return $new;
     }
index 1a30b476dcecb30a203be2c78dafcfa2341e817b..fe6858bed2e55932e5d9d7892aa390cc76ba9bb3 100644 (file)
@@ -190,11 +190,8 @@ class Repository_Post
             ->addArgument($repo->workDir)
             ->execute();
 
-        foreach (glob($repo->gitDir . '/hooks/*') as $hookfile) {
-            unlink($hookfile);
-        }
-
-        touch($repo->gitDir . '/git-daemon-export-ok');
+        $rs = new Repository_Setup($repo);
+        $rs->afterInit();
 
         return $repo;
     }
diff --git a/src/phorkie/Repository/Setup.php b/src/phorkie/Repository/Setup.php
new file mode 100644 (file)
index 0000000..e26338b
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+namespace phorkie;
+
+class Repository_Setup
+{
+    protected $repo;
+
+    public function __construct(Repository $repo)
+    {
+        $this->repo = $repo;
+    }
+
+    /**
+     * Should be called right after a repository has been created,
+     * either by "git init" or "git clone".
+     * Takes care of removing hook example files and creating
+     * the git daemon export file
+     *
+     * @return void
+     */
+    public function afterInit()
+    {
+        foreach (glob($this->repo->gitDir . '/hooks/*') as $hookfile) {
+            unlink($hookfile);
+        }
+        touch($this->repo->gitDir . '/git-daemon-export-ok');
+    }
+
+}
+
+?>