Merge branch '1.5'
commit
a8df30c09b
|
@ -164,10 +164,24 @@ class Compiler
|
|||
$util->save($pharFile, \Phar::SHA1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \SplFileInfo $file
|
||||
* @return string
|
||||
*/
|
||||
private function getRelativeFilePath($file)
|
||||
{
|
||||
$realPath = $file->getRealPath();
|
||||
$pathPrefix = dirname(dirname(__DIR__)).DIRECTORY_SEPARATOR;
|
||||
|
||||
$pos = strpos($realPath, $pathPrefix);
|
||||
$relativePath = ($pos !== false) ? substr_replace($realPath, '', $pos, strlen($pathPrefix)) : $realPath;
|
||||
|
||||
return strtr($relativePath, '\\', '/');
|
||||
}
|
||||
|
||||
private function addFile($phar, $file, $strip = true)
|
||||
{
|
||||
$path = strtr(str_replace(dirname(dirname(__DIR__)).DIRECTORY_SEPARATOR, '', $file->getRealPath()), '\\', '/');
|
||||
|
||||
$path = $this->getRelativeFilePath($file);
|
||||
$content = file_get_contents($file);
|
||||
if ($strip) {
|
||||
$content = $this->stripWhitespace($content);
|
||||
|
|
|
@ -12,12 +12,14 @@
|
|||
|
||||
namespace Composer\Downloader;
|
||||
|
||||
use Composer\Package\Archiver\ArchivableFilesFinder;
|
||||
use Composer\Package\Dumper\ArrayDumper;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Package\Version\VersionGuesser;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Util\Platform;
|
||||
use Composer\Util\ProcessExecutor;
|
||||
use Composer\Util\Filesystem as ComposerFilesystem;
|
||||
use Symfony\Component\Filesystem\Exception\IOException;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
|
@ -118,8 +120,12 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
|||
|
||||
// Fallback if symlink failed or if symlink is not allowed for the package
|
||||
if (self::STRATEGY_MIRROR == $currentStrategy) {
|
||||
$fs = new ComposerFilesystem();
|
||||
$realUrl = $fs->normalizePath($realUrl);
|
||||
|
||||
$this->io->writeError(sprintf('%sMirroring from %s', $isFallback ? ' ' : '', $url), false);
|
||||
$fileSystem->mirror($realUrl, $path);
|
||||
$iterator = new ArchivableFilesFinder($realUrl, array());
|
||||
$fileSystem->mirror($realUrl, $path, $iterator);
|
||||
}
|
||||
|
||||
$this->io->writeError('');
|
||||
|
|
|
@ -1309,7 +1309,7 @@ class Installer
|
|||
$skipPackages[$require->getTarget()] = true;
|
||||
}
|
||||
|
||||
$pool = new Pool;
|
||||
$pool = new Pool('dev');
|
||||
$pool->addRepository($localOrLockRepo);
|
||||
|
||||
$seen = array();
|
||||
|
|
|
@ -308,7 +308,12 @@ class GitLabDriver extends VcsDriver
|
|||
// we need to fetch the default branch from the api
|
||||
$resource = $this->getApiUrl();
|
||||
$this->project = JsonFile::parseJson($this->getContents($resource, true), $resource);
|
||||
if (isset($this->project['visibility'])) {
|
||||
$this->isPrivate = $this->project['visibility'] !== 'public';
|
||||
} else {
|
||||
// client is not authendicated, therefore repository has to be public
|
||||
$this->isPrivate = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function attemptCloneFallback()
|
||||
|
|
|
@ -142,6 +142,44 @@ JSON;
|
|||
return $driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInitializeUrls
|
||||
*/
|
||||
public function testInitializePublicProjectAsAnonymous($url, $apiUrl)
|
||||
{
|
||||
// @link http://doc.gitlab.com/ce/api/projects.html#get-single-project
|
||||
$projectData = <<<JSON
|
||||
{
|
||||
"id": 17,
|
||||
"default_branch": "mymaster",
|
||||
"http_url_to_repo": "https://gitlab.com/mygroup/myproject.git",
|
||||
"ssh_url_to_repo": "git@gitlab.com:mygroup/myproject.git",
|
||||
"last_activity_at": "2014-12-01T09:17:51.000+01:00",
|
||||
"name": "My Project",
|
||||
"name_with_namespace": "My Group / My Project",
|
||||
"path": "myproject",
|
||||
"path_with_namespace": "mygroup/myproject",
|
||||
"web_url": "https://gitlab.com/mygroup/myproject"
|
||||
}
|
||||
JSON;
|
||||
|
||||
$this->remoteFilesystem
|
||||
->getContents('gitlab.com', $apiUrl, false, array())
|
||||
->willReturn($projectData)
|
||||
->shouldBeCalledTimes(1)
|
||||
;
|
||||
|
||||
$driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $this->config, $this->process->reveal(), $this->remoteFilesystem->reveal());
|
||||
$driver->initialize();
|
||||
|
||||
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
|
||||
$this->assertEquals('mymaster', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab');
|
||||
$this->assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default');
|
||||
$this->assertEquals('https://gitlab.com/mygroup/myproject', $driver->getUrl());
|
||||
|
||||
return $driver;
|
||||
}
|
||||
|
||||
public function testGetDist()
|
||||
{
|
||||
$driver = $this->testInitialize('https://gitlab.com/mygroup/myproject', 'https://gitlab.com/api/v4/projects/mygroup%2Fmyproject');
|
||||
|
|
Loading…
Reference in New Issue