1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-10 09:02:59 +00:00

Merge remote-tracking branch 'burci/feature/path_downloader_option_to_force_copy'

This commit is contained in:
Jordi Boggiano 2016-02-25 11:42:47 +00:00
commit 4df7ade801
3 changed files with 92 additions and 13 deletions

View file

@ -41,7 +41,14 @@ use Composer\Util\ProcessExecutor;
* {
* "type": "path",
* "url": "/absolute/path/to/several/packages/*"
* }
* },
* {
* "type": "path",
* "url": "../../relative/path/to/package/",
* "options": {
* "symlink": false
* }
* },
* ]
* @endcode
*
@ -75,6 +82,11 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
*/
private $process;
/**
* @var array
*/
private $options;
/**
* Initializes path repository.
*
@ -88,11 +100,12 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
throw new \RuntimeException('You must specify the `url` configuration for the path repository');
}
$this->loader = new ArrayLoader();
$this->loader = new ArrayLoader(null, true);
$this->url = $repoConfig['url'];
$this->process = new ProcessExecutor($io);
$this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser());
$this->repoConfig = $repoConfig;
$this->options = isset($repoConfig['options']) ? $repoConfig['options'] : array();
parent::__construct();
}
@ -126,6 +139,7 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
'url' => $url,
'reference' => sha1($json),
);
$package['transport-options'] = $this->getOptions();
if (!isset($package['version'])) {
$package['version'] = $this->versionGuesser->guessVersion($package, $path) ?: 'dev-master';
@ -135,7 +149,6 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H', $output, $path)) {
$package['dist']['reference'] = trim($output);
}
$package = $this->loader->load($package);
$this->addPackage($package);
}
@ -153,4 +166,20 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
return str_replace(DIRECTORY_SEPARATOR, '/', $val);
}, glob($this->url, GLOB_MARK | GLOB_ONLYDIR));
}
/**
* @return array
*/
public function getOptions()
{
return $this->options;
}
/**
* @param array $options
*/
public function setOptions($options)
{
$this->options = $options;
}
}