1
0
Fork 0

fix typo and bugs on Fossil support

pull/5467/head
bohwaz 2016-06-23 17:14:53 +12:00
parent 49a94ca7fd
commit 5674262030
3 changed files with 15 additions and 8 deletions

View File

@ -32,7 +32,7 @@ class FossilDownloader extends VcsDownloader
$ref = ProcessExecutor::escape($package->getSourceReference()); $ref = ProcessExecutor::escape($package->getSourceReference());
$repoFile = $path . '.fossil'; $repoFile = $path . '.fossil';
$this->io->writeError(" Cloning ".$package->getSourceReference($repoFile)); $this->io->writeError(" Cloning ".$package->getSourceReference($repoFile));
$command = sprintf('fossil clone %s %s', $url, ProcessExecutor::escape()); $command = sprintf('fossil clone %s %s', $url, ProcessExecutor::escape($repoFile));
if (0 !== $this->process->execute($command, $ignoredOutput)) { if (0 !== $this->process->execute($command, $ignoredOutput)) {
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()); throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
} }

View File

@ -63,7 +63,7 @@ class FossilDriver extends VcsDriver
$fs->ensureDirectoryExists($this->checkoutDir); $fs->ensureDirectoryExists($this->checkoutDir);
if (0 !== $this->process->execute(sprintf('fossil clone %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoFile)), $output, $cacheDir)) { if (0 !== $this->process->execute(sprintf('fossil clone %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoFile)), $output)) {
$output = $this->process->getErrorOutput(); $output = $this->process->getErrorOutput();
if (0 !== $this->process->execute('fossil version', $ignoredOutput)) { if (0 !== $this->process->execute('fossil version', $ignoredOutput)) {
@ -127,16 +127,17 @@ class FossilDriver extends VcsDriver
public function getComposerInformation($identifier) public function getComposerInformation($identifier)
{ {
if (!isset($this->infoCache[$identifier])) { if (!isset($this->infoCache[$identifier])) {
$this->process->execute(sprintf('fossil -r %s composer.json', ProcessExecutor::escape($identifier)), $composer, $this->checkoutDir); $command = sprintf('fossil cat -r %s composer.json', ProcessExecutor::escape($identifier));
$this->process->execute($command, $composer, $this->checkoutDir);
if (!trim($composer)) { if (trim($composer) === '') {
return; return;
} }
$composer = JsonFile::parseJson($composer, $identifier); $composer = JsonFile::parseJson(trim($composer), $identifier);
if (empty($composer['time'])) { if (empty($composer['time'])) {
$this->process->execute(sprintf('fossil finfo -r %s | head -n 2 | tail -n 1 | awk \'{print $1}\'', ProcessExecutor::escape($identifier)), $output, $this->checkoutDir); $this->process->execute(sprintf('fossil finfo composer.json | head -n 2 | tail -n 1 | awk \'{print $1}\''), $output, $this->checkoutDir);
$date = new \DateTime(trim($output), new \DateTimeZone('UTC')); $date = new \DateTime(trim($output), new \DateTimeZone('UTC'));
$composer['time'] = $date->format('Y-m-d H:i:s'); $composer['time'] = $date->format('Y-m-d H:i:s');
} }
@ -176,6 +177,7 @@ class FossilDriver extends VcsDriver
$this->process->execute('fossil branch list', $output, $this->checkoutDir); $this->process->execute('fossil branch list', $output, $this->checkoutDir);
foreach ($this->process->splitLines($output) as $branch) { foreach ($this->process->splitLines($output) as $branch) {
$branch = trim(preg_replace('/^\*/', '', trim($branch)));
$branches[$branch] = $branch; $branches[$branch] = $branch;
} }
@ -190,7 +192,12 @@ class FossilDriver extends VcsDriver
*/ */
public static function supports(IOInterface $io, Config $config, $url, $deep = false) public static function supports(IOInterface $io, Config $config, $url, $deep = false)
{ {
if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?chiselapp\.com)#i', $url)) { if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i', $url)) {
return true;
}
if (preg_match('!/fossil/|\.fossil!', $url))
{
return true; return true;
} }

View File

@ -53,7 +53,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver', 'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver',
'hg' => 'Composer\Repository\Vcs\HgDriver', 'hg' => 'Composer\Repository\Vcs\HgDriver',
'perforce' => 'Composer\Repository\Vcs\PerforceDriver', 'perforce' => 'Composer\Repository\Vcs\PerforceDriver',
'fossil' => 'Composer\Repository\Vcs\Fossil', 'fossil' => 'Composer\Repository\Vcs\FossilDriver',
// svn must be last because identifying a subversion server for sure is practically impossible // svn must be last because identifying a subversion server for sure is practically impossible
'svn' => 'Composer\Repository\Vcs\SvnDriver', 'svn' => 'Composer\Repository\Vcs\SvnDriver',
); );