1
0
Fork 0

Merge remote-tracking branch 'spaun/master'

pull/1704/merge
Jordi Boggiano 2013-04-27 17:36:05 +02:00
commit 895058d1ce
3 changed files with 30 additions and 5 deletions

0
src/Composer/Repository/Vcs/GitHubDriver.php Executable file → Normal file
View File

0
src/Composer/Repository/Vcs/HgDriver.php Executable file → Normal file
View File

35
src/Composer/Repository/Vcs/SvnDriver.php Executable file → Normal file
View File

@ -36,6 +36,7 @@ class SvnDriver extends VcsDriver
protected $trunkPath = 'trunk'; protected $trunkPath = 'trunk';
protected $branchesPath = 'branches'; protected $branchesPath = 'branches';
protected $tagsPath = 'tags'; protected $tagsPath = 'tags';
protected $packagePath = '';
/** /**
* @var \Composer\Util\Svn * @var \Composer\Util\Svn
@ -58,6 +59,9 @@ class SvnDriver extends VcsDriver
if (isset($this->repoConfig['tags-path'])) { if (isset($this->repoConfig['tags-path'])) {
$this->tagsPath = $this->repoConfig['tags-path']; $this->tagsPath = $this->repoConfig['tags-path'];
} }
if (isset($this->repoConfig['package-path'])) {
$this->packagePath = '/' . trim($this->repoConfig['package-path'], '/');
}
if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) { if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) {
$this->baseUrl = substr($this->url, 0, $pos); $this->baseUrl = substr($this->url, 0, $pos);
@ -167,8 +171,10 @@ class SvnDriver extends VcsDriver
$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], '/')] = '/' . $this->tagsPath . $this->tags[rtrim($match[2], '/')] = $this->buildIdentifier(
'/' . $match[2] . '@' . $match[1]; '/' . $this->tagsPath . '/' . $match[2],
$match[1]
);
} }
} }
} }
@ -193,7 +199,10 @@ class SvnDriver extends VcsDriver
$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] === $this->trunkPath . '/') { if (isset($match[1]) && isset($match[2]) && $match[2] === $this->trunkPath . '/') {
$this->branches[$this->trunkPath] = '/' . $this->trunkPath . '/@'.$match[1]; $this->branches[$this->trunkPath] = $this->buildIdentifier(
'/' . $this->trunkPath,
$match[1]
);
$this->rootIdentifier = $this->branches[$this->trunkPath]; $this->rootIdentifier = $this->branches[$this->trunkPath];
break; break;
} }
@ -209,8 +218,10 @@ class SvnDriver extends VcsDriver
$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], '/')] = '/' . $this->branchesPath . $this->branches[rtrim($match[2], '/')] = $this->buildIdentifier(
'/' . $match[2] . '@' . $match[1]; '/' . $this->branchesPath . '/' . $match[2],
$match[1]
);
} }
} }
} }
@ -301,4 +312,18 @@ class SvnDriver extends VcsDriver
); );
} }
} }
/**
* Build the identifier respecting "package-path" config option
*
* @param string $baseDir The path to trunk/branch/tag
* @param int $revision The revision mark to add to identifier
*
* @return string
*/
protected function buildIdentifier($baseDir, $revision)
{
return rtrim($baseDir, '/') . $this->packagePath . '/@' . $revision;
}
} }