use repositories class
[phorkie.git] / src / Phorkie / Repository.php
index ebd420f431374abed39c96ffa1332078665ac82e..f23db7e17faea3f6d7569b27b1c7d9bd11da0fb1 100644 (file)
@@ -42,6 +42,11 @@ class Repository
         $this->repoDir = $repoDir;
     }
 
+    public function getVc()
+    {
+        return new \VersionControl_Git($this->repoDir);
+    }
+
     /**
      * Loads the list of files in this repository
      *
@@ -72,6 +77,9 @@ class Repository
 
     public function getDescription()
     {
+        if (!is_readable($this->repoDir . '/.git/description')) {
+            return null;
+        }
         return file_get_contents($this->repoDir . '/.git/description');
     }
 
@@ -81,6 +89,7 @@ class Repository
      * @param string $type Link type. Supported are:
      *                     - "edit"
      *                     - "display"
+     *                     - "fork"
      *
      * @return string
      */
@@ -90,6 +99,8 @@ class Repository
             return '/' . $this->id . '/edit';
         } else if ($type == 'display') {
             return '/' . $this->id;
+        } else if ($type == 'fork') {
+            return '/' . $this->id . '/fork';
         }
         throw new Exception('Unknown type');
     }