From 340e9606143ec7e59613aa6b1b343c1c5b5f5bfa Mon Sep 17 00:00:00 2001 From: Andrey Utkin Date: Tue, 23 Apr 2013 12:27:52 +0700 Subject: [PATCH 1/3] Allow svn repositories to reside deeper than module root --- src/Composer/Repository/Vcs/GitHubDriver.php | 0 src/Composer/Repository/Vcs/HgDriver.php | 0 src/Composer/Repository/Vcs/SvnDriver.php | 35 +++++++++++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-) mode change 100755 => 100644 src/Composer/Repository/Vcs/GitHubDriver.php mode change 100755 => 100644 src/Composer/Repository/Vcs/HgDriver.php mode change 100755 => 100644 src/Composer/Repository/Vcs/SvnDriver.php diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php old mode 100755 new mode 100644 diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php old mode 100755 new mode 100644 diff --git a/src/Composer/Repository/Vcs/SvnDriver.php b/src/Composer/Repository/Vcs/SvnDriver.php old mode 100755 new mode 100644 index af42c1f9b..f38290063 --- a/src/Composer/Repository/Vcs/SvnDriver.php +++ b/src/Composer/Repository/Vcs/SvnDriver.php @@ -36,6 +36,7 @@ class SvnDriver extends VcsDriver protected $trunkPath = 'trunk'; protected $branchesPath = 'branches'; protected $tagsPath = 'tags'; + protected $modulePath = '/'; /** * @var \Composer\Util\Svn @@ -58,6 +59,9 @@ class SvnDriver extends VcsDriver if (isset($this->repoConfig['tags-path'])) { $this->tagsPath = $this->repoConfig['tags-path']; } + if (isset($this->repoConfig['module-path'])) { + $this->modulePath = '/' . trim($this->repoConfig['module-path'], '/'); + } if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) { $this->baseUrl = substr($this->url, 0, $pos); @@ -167,8 +171,10 @@ class SvnDriver extends VcsDriver $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], '/')] = '/' . $this->tagsPath . - '/' . $match[2] . '@' . $match[1]; + $this->tags[rtrim($match[2], '/')] = $this->buildModuleId( + '/' . $this->tagsPath . '/' . $match[2], + $match[1] + ); } } } @@ -193,7 +199,10 @@ class SvnDriver extends VcsDriver $line = trim($line); if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) { if (isset($match[1]) && isset($match[2]) && $match[2] === $this->trunkPath . '/') { - $this->branches[$this->trunkPath] = '/' . $this->trunkPath . '/@'.$match[1]; + $this->branches[$this->trunkPath] = $this->buildModuleId( + '/' . $this->trunkPath, + $match[1] + ); $this->rootIdentifier = $this->branches[$this->trunkPath]; break; } @@ -209,8 +218,10 @@ class SvnDriver extends VcsDriver $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], '/')] = '/' . $this->branchesPath . - '/' . $match[2] . '@' . $match[1]; + $this->branches[rtrim($match[2], '/')] = $this->buildModuleId( + '/' . $this->branchesPath . '/' . $match[2], + $match[1] + ); } } } @@ -301,4 +312,18 @@ class SvnDriver extends VcsDriver ); } } + + /** + * Build module identifier respecting the module-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 buildModuleId($baseDir, $revision) + { + return rtrim($baseDir, '/') . $this->modulePath . '/@' . $revision; + } } + From 9022b0ae38534bd4cb07b69c9f078f8b33adad10 Mon Sep 17 00:00:00 2001 From: Andrey Utkin Date: Wed, 24 Apr 2013 09:32:16 +0700 Subject: [PATCH 2/3] Default module path to empty string --- src/Composer/Repository/Vcs/SvnDriver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Repository/Vcs/SvnDriver.php b/src/Composer/Repository/Vcs/SvnDriver.php index f38290063..0b0f40175 100644 --- a/src/Composer/Repository/Vcs/SvnDriver.php +++ b/src/Composer/Repository/Vcs/SvnDriver.php @@ -36,7 +36,7 @@ class SvnDriver extends VcsDriver protected $trunkPath = 'trunk'; protected $branchesPath = 'branches'; protected $tagsPath = 'tags'; - protected $modulePath = '/'; + protected $modulePath = ''; /** * @var \Composer\Util\Svn From 28c219311c2de30dd2bc645066f4508146f0576a Mon Sep 17 00:00:00 2001 From: Andrey Utkin Date: Sat, 27 Apr 2013 22:20:50 +0700 Subject: [PATCH 3/3] Rename module-path to package-path --- src/Composer/Repository/Vcs/SvnDriver.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Composer/Repository/Vcs/SvnDriver.php b/src/Composer/Repository/Vcs/SvnDriver.php index 0b0f40175..f47722bc4 100644 --- a/src/Composer/Repository/Vcs/SvnDriver.php +++ b/src/Composer/Repository/Vcs/SvnDriver.php @@ -36,7 +36,7 @@ class SvnDriver extends VcsDriver protected $trunkPath = 'trunk'; protected $branchesPath = 'branches'; protected $tagsPath = 'tags'; - protected $modulePath = ''; + protected $packagePath = ''; /** * @var \Composer\Util\Svn @@ -59,8 +59,8 @@ class SvnDriver extends VcsDriver if (isset($this->repoConfig['tags-path'])) { $this->tagsPath = $this->repoConfig['tags-path']; } - if (isset($this->repoConfig['module-path'])) { - $this->modulePath = '/' . trim($this->repoConfig['module-path'], '/'); + if (isset($this->repoConfig['package-path'])) { + $this->packagePath = '/' . trim($this->repoConfig['package-path'], '/'); } if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) { @@ -171,7 +171,7 @@ class SvnDriver extends VcsDriver $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], '/')] = $this->buildModuleId( + $this->tags[rtrim($match[2], '/')] = $this->buildIdentifier( '/' . $this->tagsPath . '/' . $match[2], $match[1] ); @@ -199,7 +199,7 @@ class SvnDriver extends VcsDriver $line = trim($line); if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) { if (isset($match[1]) && isset($match[2]) && $match[2] === $this->trunkPath . '/') { - $this->branches[$this->trunkPath] = $this->buildModuleId( + $this->branches[$this->trunkPath] = $this->buildIdentifier( '/' . $this->trunkPath, $match[1] ); @@ -218,7 +218,7 @@ class SvnDriver extends VcsDriver $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], '/')] = $this->buildModuleId( + $this->branches[rtrim($match[2], '/')] = $this->buildIdentifier( '/' . $this->branchesPath . '/' . $match[2], $match[1] ); @@ -314,16 +314,16 @@ class SvnDriver extends VcsDriver } /** - * Build module identifier respecting the module-path config option + * 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 buildModuleId($baseDir, $revision) + protected function buildIdentifier($baseDir, $revision) { - return rtrim($baseDir, '/') . $this->modulePath . '/@' . $revision; + return rtrim($baseDir, '/') . $this->packagePath . '/@' . $revision; } }