mirror of
https://github.com/composer/composer
synced 2025-05-09 16:42:57 +00:00
Add support for alternative structures
This commit is contained in:
parent
e2f8098f53
commit
93628c42d8
2 changed files with 28 additions and 8 deletions
|
@ -32,6 +32,10 @@ class SvnDriver extends VcsDriver
|
||||||
protected $branches;
|
protected $branches;
|
||||||
protected $infoCache = array();
|
protected $infoCache = array();
|
||||||
|
|
||||||
|
protected $trunkLocation = 'trunk';
|
||||||
|
protected $branchesLocation = 'branches';
|
||||||
|
protected $tagsLocation = 'tags';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Composer\Util\Svn
|
* @var \Composer\Util\Svn
|
||||||
*/
|
*/
|
||||||
|
@ -43,8 +47,18 @@ class SvnDriver extends VcsDriver
|
||||||
public function initialize()
|
public function initialize()
|
||||||
{
|
{
|
||||||
$this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/');
|
$this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/');
|
||||||
|
|
||||||
|
if ($this->config->has('trunkLocation')) {
|
||||||
|
$this->trunkLocation = $this->config->get('trunkLocation');
|
||||||
|
}
|
||||||
|
if ($this->config->has('branchesLocation')) {
|
||||||
|
$this->branchesLocation = $this->config->get('branchesLocation');
|
||||||
|
}
|
||||||
|
if ($this->config->has('tagsLocation')) {
|
||||||
|
$this->tagsLocation = $this->config->get('tagsLocation');
|
||||||
|
}
|
||||||
|
|
||||||
if (false !== ($pos = strrpos($this->url, '/trunk'))) {
|
if (false !== ($pos = strrpos($this->url, '/' . $this->trunkLocation))) {
|
||||||
$this->baseUrl = substr($this->url, 0, $pos);
|
$this->baseUrl = substr($this->url, 0, $pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +73,7 @@ class SvnDriver extends VcsDriver
|
||||||
*/
|
*/
|
||||||
public function getRootIdentifier()
|
public function getRootIdentifier()
|
||||||
{
|
{
|
||||||
return 'trunk';
|
return $this->trunkLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -145,13 +159,14 @@ class SvnDriver extends VcsDriver
|
||||||
if (null === $this->tags) {
|
if (null === $this->tags) {
|
||||||
$this->tags = array();
|
$this->tags = array();
|
||||||
|
|
||||||
$output = $this->execute('svn ls --verbose', $this->baseUrl . '/tags');
|
$output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->tagsLocation);
|
||||||
if ($output) {
|
if ($output) {
|
||||||
foreach ($this->process->splitLines($output) as $line) {
|
foreach ($this->process->splitLines($output) as $line) {
|
||||||
$line = trim($line);
|
$line = trim($line);
|
||||||
if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
|
if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
|
||||||
if (isset($match[1]) && isset($match[2]) && $match[2] !== './') {
|
if (isset($match[1]) && isset($match[2]) && $match[2] !== './') {
|
||||||
$this->tags[rtrim($match[2], '/')] = '/tags/'.$match[2].'@'.$match[1];
|
$this->tags[rtrim($match[2], '/')] = '/' . $this->tagsLocation .
|
||||||
|
'/' . $match[2] . '@' . $match[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,8 +189,9 @@ class SvnDriver extends VcsDriver
|
||||||
foreach ($this->process->splitLines($output) as $line) {
|
foreach ($this->process->splitLines($output) as $line) {
|
||||||
$line = trim($line);
|
$line = trim($line);
|
||||||
if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
|
if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
|
||||||
if (isset($match[1]) && isset($match[2]) && $match[2] === 'trunk/') {
|
if (isset($match[1]) && isset($match[2]) && $match[2] === $this->trunkLocation . '/') {
|
||||||
$this->branches['trunk'] = '/trunk/@'.$match[1];
|
$this->branches[$this->trunkLocation] = '/' . $this->trunkLocation .
|
||||||
|
'/@'.$match[1];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,13 +199,14 @@ class SvnDriver extends VcsDriver
|
||||||
}
|
}
|
||||||
unset($output);
|
unset($output);
|
||||||
|
|
||||||
$output = $this->execute('svn ls --verbose', $this->baseUrl . '/branches');
|
$output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->branchesLocation);
|
||||||
if ($output) {
|
if ($output) {
|
||||||
foreach ($this->process->splitLines(trim($output)) as $line) {
|
foreach ($this->process->splitLines(trim($output)) as $line) {
|
||||||
$line = trim($line);
|
$line = trim($line);
|
||||||
if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
|
if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
|
||||||
if (isset($match[1]) && isset($match[2]) && $match[2] !== './') {
|
if (isset($match[1]) && isset($match[2]) && $match[2] !== './') {
|
||||||
$this->branches[rtrim($match[2], '/')] = '/branches/'.$match[2].'@'.$match[1];
|
$this->branches[rtrim($match[2], '/')] = '/' . $this->branchesLocation .
|
||||||
|
'/' . $match[2] . '@' . $match[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,9 @@ class VcsRepository extends ArrayRepository
|
||||||
$this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
|
$this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
|
||||||
$this->verbose = $io->isVerbose();
|
$this->verbose = $io->isVerbose();
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
if (isset($repoConfig['config']) && is_array($repoConfig['config'])) {
|
||||||
|
$this->config->merge(array('config' => $repoConfig['config']));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLoader(LoaderInterface $loader)
|
public function setLoader(LoaderInterface $loader)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue