Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add config option for SvnDriver to allow Symfony-like package structure in svn #1819

Merged
merged 3 commits into from

2 participants

@spaun

This patch will add the module-path config option for svn-based repositories. This option allows placing package source code not in svn module root, thus making it possible to organize you library in the way Symfony2 of ZF2 frameworks do.

For example we have following repository structure:

/core-package-name/trunk/composer.json <-- complete library
/core-package-name/trunk/Company/Package/Class.php
/core-package-name/trunk/Company/Package/composer.json <-- single package

Or something like this:

/some-module/trunk/some-historical-path/Company/Package/Class.php
/some-module/trunk/some-historical-path/composer.json

In both cases Satis will fail to build packages.json (in first case for Package) because it will not be able to find composer.json.

The module-path is path from trunk/branches/tags to composer.json

@Seldaek
Owner

I agree this might be good for svn users, but one issue is that it makes migrating to git harder if you start laying out your packages like that.

@spaun

Unfortunately we already have such a layout. And we can't change it right now. The idea was to configure custom composer repository for new projects and then update older projects one by one.

BTW, why do you think it would be harder to migrate?

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 = '/';
@Seldaek Owner
Seldaek added a note

I think it should default to an empty string, otherwise you'll create urls like /trunk//@123 no?

@spaun
spaun added a note

Yes, you're right. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Seldaek
Owner

OK one more thing sorry I didn't pay attention before but could you rename module-path to package-path (and ideally all vars/methods that contain module)? We don't refer to packages as modules anywhere in composer, so that's kinda weird.

@spaun

Yes, sure, this sounds better. Will do it tomorrow

@Seldaek Seldaek merged commit 28c2193 into composer:master
@spaun

Thanks:)

@Ocramius Ocramius referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@digitalkaoz digitalkaoz referenced this pull request from a commit in digitalkaoz/composer
@Seldaek Seldaek Add docs about package-path, refs #1819 8c7fbd8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 23, 2013
  1. @spaun
Commits on Apr 24, 2013
  1. @spaun
Commits on Apr 27, 2013
  1. @spaun
This page is out of date. Refresh to see the latest.
View
0  src/Composer/Repository/Vcs/GitHubDriver.php 100755 → 100644
File mode changed
View
0  src/Composer/Repository/Vcs/HgDriver.php 100755 → 100644
File mode changed
View
35 src/Composer/Repository/Vcs/SvnDriver.php 100755 → 100644
@@ -36,6 +36,7 @@ class SvnDriver extends VcsDriver
protected $trunkPath = 'trunk';
protected $branchesPath = 'branches';
protected $tagsPath = 'tags';
+ protected $packagePath = '';
/**
* @var \Composer\Util\Svn
@@ -58,6 +59,9 @@ public function initialize()
if (isset($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))) {
$this->baseUrl = substr($this->url, 0, $pos);
@@ -167,8 +171,10 @@ public function getTags()
$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->buildIdentifier(
+ '/' . $this->tagsPath . '/' . $match[2],
+ $match[1]
+ );
}
}
}
@@ -193,7 +199,10 @@ public function getBranches()
$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->buildIdentifier(
+ '/' . $this->trunkPath,
+ $match[1]
+ );
$this->rootIdentifier = $this->branches[$this->trunkPath];
break;
}
@@ -209,8 +218,10 @@ public function getBranches()
$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->buildIdentifier(
+ '/' . $this->branchesPath . '/' . $match[2],
+ $match[1]
+ );
}
}
}
@@ -301,4 +312,18 @@ protected function execute($command, $url)
);
}
}
+
+ /**
+ * 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;
+ }
}
+
Something went wrong with that request. Please try again.