do not try to delete if file does not exist
[phorkie.git] / src / phorkie / ForkRemote.php
index c9ed748ad189f7f841cc2e6e96255e48f3d47b59..3f6a4787ce818f89d4b37a940ffc5abcd0ff126e 100644 (file)
@@ -17,18 +17,20 @@ class ForkRemote
 
     public function __construct($url)
     {
-        $this->url = $url;
+        $this->url = trim($url);
     }
 
     public function parse()
     {
-        $arUrl = parse_url($this->url);
+        $arUrl  = parse_url($this->url);
         $scheme = $arUrl['scheme'] ?: '';
+
         if ($scheme == 'https' && isset($arUrl['host'])
             && $arUrl['host'] == 'gist.github.com'
         ) {
-            $scheme = 'git';
-            $this->url = 'git://gist.github.com/'. ltrim($arUrl['path'], '/') . '.git';
+            $this->arGitUrls[][] = 'git://gist.github.com/'
+                . ltrim($arUrl['path'], '/') . '.git';
+            return true;
         }
 
         switch ($scheme) {
@@ -113,6 +115,22 @@ class ForkRemote
         return $this->arGitUrls;
     }
 
+    /**
+     * Get the URL from which the git URL was derived, often
+     * the HTTP URL.
+     *
+     * @return string
+     */
+    public function getUrl()
+    {
+        return $this->url;
+    }
+
+    public function setUrl($url)
+    {
+        $this->url = $url;
+    }
+
     public function isSupported($url)
     {
         return parse_url($url, PHP_URL_SCHEME) == 'git';