Skip to content

Commit

Permalink
Fix workflow & typos
Browse files Browse the repository at this point in the history
  • Loading branch information
MattKetmo authored and naderman committed Mar 28, 2013
1 parent c248115 commit 9d24e17
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/Composer/Package/Archiver/ArchiveManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ public function archive(PackageInterface $package, $format, $targetDir)
// 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);
}
}
2 changes: 1 addition & 1 deletion src/Composer/Package/Archiver/ArchiverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Package/Archiver/GitArchiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function archive($sources, $target, $format, $sourceRef = null)
'git archive --format %s --output %s %s',
$format,
escapeshellarg($target),
$sourceRef
escapeshellarg($sourceRef)
);

$exitCode = $this->process->execute($command, $output, $sources);
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Package/Archiver/MercurialArchiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function archive($sources, $target, $format, $sourceRef = null)

$command = sprintf(
'hg archive --rev %s --type %s %s',
$sourceRef,
escapeshellarg($sourceRef),
$format,
escapeshellarg($target)
);
Expand Down
30 changes: 9 additions & 21 deletions src/Composer/Package/Archiver/PharArchiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -64,4 +44,12 @@ protected function createPharArchive($sources, $target, $format)
throw new \RuntimeException($message, $e->getCode(), $e);
}
}

/**
* {@inheritdoc}
*/
public function supports($format, $sourceType)
{
return isset(static::$formats[$format]);
}
}
3 changes: 3 additions & 0 deletions tests/Composer/Test/Package/Archiver/ArchiverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,19 @@ protected function setupGitRepo()

$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());
}

Expand Down

0 comments on commit 9d24e17

Please sign in to comment.