1
0
Fork 0

Add support for unixy paths in git/hg local repo urls, closes #3294

pull/3294/merge
Jordi Boggiano 2014-09-24 19:13:05 +01:00
parent 55a6a1c3d4
commit 91ac3e1426
4 changed files with 13 additions and 4 deletions

View File

@ -225,12 +225,12 @@ class GitDriver extends VcsDriver
// local filesystem // local filesystem
if (Filesystem::isLocalPath($url)) { if (Filesystem::isLocalPath($url)) {
$url = Filesystem::getPlatformPath($url);
if (!is_dir($url)) { if (!is_dir($url)) {
throw new \RuntimeException('Directory does not exist: '.$url); throw new \RuntimeException('Directory does not exist: '.$url);
} }
$process = new ProcessExecutor(); $process = new ProcessExecutor($io);
$url = str_replace('file://', '', $url);
// check whether there is a git repo in that path // check whether there is a git repo in that path
if ($process->execute('git tag', $output, $url) === 0) { if ($process->execute('git tag', $output, $url) === 0) {
return true; return true;

View File

@ -198,12 +198,12 @@ class HgDriver extends VcsDriver
// local filesystem // local filesystem
if (Filesystem::isLocalPath($url)) { if (Filesystem::isLocalPath($url)) {
$url = Filesystem::getPlatformPath($url);
if (!is_dir($url)) { if (!is_dir($url)) {
throw new \RuntimeException('Directory does not exist: '.$url); throw new \RuntimeException('Directory does not exist: '.$url);
} }
$process = new ProcessExecutor(); $process = new ProcessExecutor();
$url = str_replace('file://', '', $url);
// check whether there is a hg repo in that path // check whether there is a hg repo in that path
if ($process->execute('hg summary', $output, $url) === 0) { if ($process->execute('hg summary', $output, $url) === 0) {
return true; return true;

View File

@ -46,7 +46,7 @@ abstract class VcsDriver implements VcsDriverInterface
final public function __construct(array $repoConfig, IOInterface $io, Config $config, ProcessExecutor $process = null, RemoteFilesystem $remoteFilesystem = null) final public function __construct(array $repoConfig, IOInterface $io, Config $config, ProcessExecutor $process = null, RemoteFilesystem $remoteFilesystem = null)
{ {
if (Filesystem::isLocalPath($repoConfig['url'])) { if (Filesystem::isLocalPath($repoConfig['url'])) {
$repoConfig['url'] = preg_replace('{^file://}', '', $repoConfig['url']); $repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']);
} }
$this->url = $repoConfig['url']; $this->url = $repoConfig['url'];

View File

@ -461,6 +461,15 @@ class Filesystem
return (bool) preg_match('{^(file://|/|[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path); return (bool) preg_match('{^(file://|/|[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
} }
public static function getPlatformPath($path)
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$path = preg_replace('{^(?:file:///([a-z])/)}i', 'file://$1:/', $path);
}
return preg_replace('{^file://}i', '', $path);
}
protected function directorySize($directory) protected function directorySize($directory)
{ {
$it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS); $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);