瀏覽代碼

Expose the Driver of the VcsRepository

Jordi Boggiano 13 年之前
父節點
當前提交
9f55335011
共有 1 個文件被更改,包括 18 次插入6 次删除
  1. 18 6
      src/Composer/Repository/VcsRepository.php

+ 18 - 6
src/Composer/Repository/VcsRepository.php

@@ -37,20 +37,32 @@ class VcsRepository extends ArrayRepository
         $this->debug = $debug;
     }
 
-    protected function initialize()
+    public function getDriver()
     {
-        parent::initialize();
-
-        $debug = $this->debug;
-
         foreach ($this->drivers as $driver) {
             if ($driver::supports($this->url)) {
                 $driver = new $driver($this->url);
                 $driver->initialize();
-                break;
+                return $driver;
+            }
+        }
+
+        foreach ($this->drivers as $driver) {
+            if ($driver::supports($this->url, true)) {
+                $driver = new $driver($this->url);
+                $driver->initialize();
+                return $driver;
             }
         }
+    }
+
+    protected function initialize()
+    {
+        parent::initialize();
+
+        $debug = $this->debug;
 
+        $driver = $this->getDriver();
         if (!$driver) {
             throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
         }