فهرست منبع

Allow local file system git repos & do not restrict to valid http* urls

Jordi Boggiano 13 سال پیش
والد
کامیت
f152fe723d
2فایلهای تغییر یافته به همراه9 افزوده شده و 4 حذف شده
  1. 9 0
      src/Composer/Repository/Vcs/GitDriver.php
  2. 0 4
      src/Composer/Repository/VcsRepository.php

+ 9 - 0
src/Composer/Repository/Vcs/GitDriver.php

@@ -169,6 +169,15 @@ class GitDriver extends VcsDriver implements VcsDriverInterface
             return true;
         }
 
+        // local filesystem
+        if (preg_match('{^(file://|/|[a-z]:[\\\\/])}', $url)) {
+            $process = new ProcessExecutor();
+            $process->execute(sprintf('cd %s && git log -1 --format=%%at', escapeshellarg($url)), $output);
+            if (is_numeric(trim($output))) {
+                return true;
+            }
+        }
+
         if (!$deep) {
             return false;
         }

+ 0 - 4
src/Composer/Repository/VcsRepository.php

@@ -19,10 +19,6 @@ class VcsRepository extends ArrayRepository
 
     public function __construct(array $config, IOInterface $io, array $drivers = null)
     {
-        if (!filter_var($config['url'], FILTER_VALIDATE_URL)) {
-            throw new \UnexpectedValueException('Invalid url given for VCS repository: '.$config['url']);
-        }
-
         $this->drivers = $drivers ?: array(
             'Composer\Repository\Vcs\GitHubDriver',
             'Composer\Repository\Vcs\GitBitbucketDriver',