Permalink
Browse files

Add support for alternative structures

  • Loading branch information...
1 parent e2f8098 commit 93628c42d84bf967a7dc5b341d2e7be85eb12f5a @bboer bboer committed Aug 29, 2012
Showing with 28 additions and 8 deletions.
  1. +25 −8 src/Composer/Repository/Vcs/SvnDriver.php
  2. +3 −0 src/Composer/Repository/VcsRepository.php
@@ -32,6 +32,10 @@ class SvnDriver extends VcsDriver
protected $branches;
protected $infoCache = array();
+ protected $trunkLocation = 'trunk';
+ protected $branchesLocation = 'branches';
+ protected $tagsLocation = 'tags';
+
/**
* @var \Composer\Util\Svn
*/
@@ -43,8 +47,18 @@ class SvnDriver extends VcsDriver
public function initialize()
{
$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);
}
@@ -59,7 +73,7 @@ public function initialize()
*/
public function getRootIdentifier()
{
- return 'trunk';
+ return $this->trunkLocation;
}
/**
@@ -145,13 +159,14 @@ public function getTags()
if (null === $this->tags) {
$this->tags = array();
- $output = $this->execute('svn ls --verbose', $this->baseUrl . '/tags');
+ $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->tagsLocation);
if ($output) {
foreach ($this->process->splitLines($output) as $line) {
$line = trim($line);
if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
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,22 +189,24 @@ public function getBranches()
foreach ($this->process->splitLines($output) as $line) {
$line = trim($line);
if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
- if (isset($match[1]) && isset($match[2]) && $match[2] === 'trunk/') {
- $this->branches['trunk'] = '/trunk/@'.$match[1];
+ if (isset($match[1]) && isset($match[2]) && $match[2] === $this->trunkLocation . '/') {
+ $this->branches[$this->trunkLocation] = '/' . $this->trunkLocation .
+ '/@'.$match[1];
break;
}
}
}
}
unset($output);
- $output = $this->execute('svn ls --verbose', $this->baseUrl . '/branches');
+ $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->branchesLocation);
if ($output) {
foreach ($this->process->splitLines(trim($output)) as $line) {
$line = trim($line);
if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
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 @@ public function __construct(array $repoConfig, IOInterface $io, Config $config,
$this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
$this->verbose = $io->isVerbose();
$this->config = $config;
+ if (isset($repoConfig['config']) && is_array($repoConfig['config'])) {
+ $this->config->merge(array('config' => $repoConfig['config']));
+ }
}
public function setLoader(LoaderInterface $loader)

0 comments on commit 93628c4

Please sign in to comment.