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 fc17753..94057fd 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 7473f16..157cb5e 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 1a30b47..fe6858b 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');
+    }
+
+}
+
+?>