From f152fe723d557fc9a5210f0bfd6ead8d32b0e0a8 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 18 Feb 2012 12:00:30 +0100 Subject: [PATCH 1/2] Allow local file system git repos & do not restrict to valid http* urls --- src/Composer/Repository/Vcs/GitDriver.php | 9 +++++++++ src/Composer/Repository/VcsRepository.php | 4 ---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index 286cf762a..f3923e4f5 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/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; } diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php index 1d6e82ab3..a2506d2df 100644 --- a/src/Composer/Repository/VcsRepository.php +++ b/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', From fa8cb14073cb9491b8e8f65a1e9f6f72953fba5b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 18 Feb 2012 12:12:02 +0100 Subject: [PATCH 2/2] Simplify check --- src/Composer/Repository/Vcs/GitDriver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index f3923e4f5..daab73dfe 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/src/Composer/Repository/Vcs/GitDriver.php @@ -172,8 +172,8 @@ class GitDriver extends VcsDriver implements VcsDriverInterface // 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))) { + // check whether there is a git repo in that path + if ($process->execute(sprintf('cd %s && git show', escapeshellarg($url)), $output) === 0) { return true; } }