Selaa lähdekoodia

fix typo and bugs on Fossil support

bohwaz 8 vuotta sitten
vanhempi
commit
5674262030

+ 1 - 1
src/Composer/Downloader/FossilDownloader.php

@@ -32,7 +32,7 @@ class FossilDownloader extends VcsDownloader
         $ref = ProcessExecutor::escape($package->getSourceReference());
         $repoFile = $path . '.fossil';
         $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)) {
             throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
         }

+ 13 - 6
src/Composer/Repository/Vcs/FossilDriver.php

@@ -63,7 +63,7 @@ class FossilDriver extends VcsDriver
 
                 $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();
 
                     if (0 !== $this->process->execute('fossil version', $ignoredOutput)) {
@@ -127,16 +127,17 @@ class FossilDriver extends VcsDriver
     public function getComposerInformation($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;
             }
 
-            $composer = JsonFile::parseJson($composer, $identifier);
+            $composer = JsonFile::parseJson(trim($composer), $identifier);
 
             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'));
                 $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);
             foreach ($this->process->splitLines($output) as $branch) {
+                $branch = trim(preg_replace('/^\*/', '', trim($branch)));
                 $branches[$branch] = $branch;
             }
 
@@ -190,7 +192,12 @@ class FossilDriver extends VcsDriver
      */
     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;
         }
 

+ 1 - 1
src/Composer/Repository/VcsRepository.php

@@ -53,7 +53,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
             'hg-bitbucket'  => 'Composer\Repository\Vcs\HgBitbucketDriver',
             'hg'            => 'Composer\Repository\Vcs\HgDriver',
             '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'           => 'Composer\Repository\Vcs\SvnDriver',
         );