1
0
Fork 0

Fix workflow & typos

pull/1567/head
Matthieu Moquet 2012-10-21 16:17:43 +02:00 committed by Nils Adermann
parent c248115e04
commit 9d24e17003
6 changed files with 19 additions and 28 deletions

View File

@ -76,18 +76,18 @@ class ArchiveManager
// Directory used to download the sources
$filesystem = new Filesystem();
$packageName = $package->getUniqueName();
$sources = sys_get_temp_dir().'/composer_archiver/'.$packageName;
$filesystem->ensureDirectoryExists($sources);
$sourcePath = sys_get_temp_dir().'/composer_archiver/'.$packageName;
$filesystem->ensureDirectoryExists($sourcePath);
// Archive filename
$target = $targetDir.'/'.$packageName.'.'.$format;
$filesystem->ensureDirectoryExists(dirname($target));
// Download sources
$this->downloadManager->download($package, $sources, true);
$this->downloadManager->download($package, $sourcePath, true);
// Create the archive
$sourceRef = $package->getSourceReference();
$usableArchiver->archive($sources, $target, $format, $sourceRef);
$usableArchiver->archive($sourcePath, $target, $format, $sourceRef);
}
}

View File

@ -23,7 +23,7 @@ interface ArchiverInterface
/**
* Create an archive from the sources.
*
* @param string $source The sources directory
* @param string $sources The sources directory
* @param string $target The target file
* @param string $format The format used for archive
* @param string $sourceRef The reference of the source to archive or null

View File

@ -42,7 +42,7 @@ class GitArchiver implements ArchiverInterface
'git archive --format %s --output %s %s',
$format,
escapeshellarg($target),
$sourceRef
escapeshellarg($sourceRef)
);
$exitCode = $this->process->execute($command, $output, $sources);

View File

@ -38,7 +38,7 @@ class MercurialArchiver implements ArchiverInterface
$command = sprintf(
'hg archive --rev %s --type %s %s',
$sourceRef,
escapeshellarg($sourceRef),
$format,
escapeshellarg($target)
);

View File

@ -30,29 +30,9 @@ class PharArchiver implements ArchiverInterface
* {@inheritdoc}
*/
public function archive($sources, $target, $format, $sourceRef = null)
{
$this->createPharArchive($sources, $target, static::$formats[$format]);
}
/**
* {@inheritdoc}
*/
public function supports($format, $sourceType)
{
return isset(static::$formats[$format]);
}
/**
* Create a PHAR archive.
*
* @param string $sources Path of the directory to archive
* @param string $target Path of the file archive to create
* @param int $format Format of the archive
*/
protected function createPharArchive($sources, $target, $format)
{
try {
$phar = new \PharData($target, null, null, $format);
$phar = new \PharData($target, null, null, static::$formats[$format]);
$phar->buildFromDirectory($sources);
} catch (\UnexpectedValueException $e) {
$message = sprintf("Could not create archive '%s' from '%s': %s",
@ -64,4 +44,12 @@ class PharArchiver implements ArchiverInterface
throw new \RuntimeException($message, $e->getCode(), $e);
}
}
/**
* {@inheritdoc}
*/
public function supports($format, $sourceType)
{
return isset(static::$formats[$format]);
}
}

View File

@ -57,16 +57,19 @@ abstract class ArchiverTest extends \PHPUnit_Framework_TestCase
$result = $this->process->execute('git init -q');
if ($result > 0) {
chdir($currentWorkDir);
throw new \RuntimeException('Could not init: '.$this->process->getErrorOutput());
}
$result = file_put_contents('b', 'a');
if (false === $result) {
chdir($currentWorkDir);
throw new \RuntimeException('Could not save file.');
}
$result = $this->process->execute('git add b && git commit -m "commit b" -q');
if ($result > 0) {
chdir($currentWorkDir);
throw new \RuntimeException('Could not commit: '.$this->process->getErrorOutput());
}