diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index b77d6bb1d..9234f46f8 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -331,8 +331,6 @@ class Factory } $am = new Archiver\ArchiveManager($dm); - $am->addArchiver(new Archiver\GitArchiver); - $am->addArchiver(new Archiver\MercurialArchiver); $am->addArchiver(new Archiver\PharArchiver); return $am; diff --git a/src/Composer/Package/Archiver/GitArchiver.php b/src/Composer/Package/Archiver/GitArchiver.php deleted file mode 100644 index 1279a8c80..000000000 --- a/src/Composer/Package/Archiver/GitArchiver.php +++ /dev/null @@ -1,62 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Package\Archiver; - -use Composer\Util\ProcessExecutor; - -/** - * @author Till Klampaeckel - * @author Matthieu Moquet - */ -class GitArchiver implements ArchiverInterface -{ - protected $process; - - public function __construct($process = null) - { - $this->process = $process ?: new ProcessExecutor(); - } - - /** - * {@inheritdoc} - */ - public function archive($sources, $target, $format, $sourceRef = null) - { - if (null === $sourceRef) { - $sourceRef = 'HEAD'; - } - - $command = sprintf( - 'git archive --format %s --output %s %s', - $format, - escapeshellarg($target), - escapeshellarg($sourceRef) - ); - - $exitCode = $this->process->execute($command, $output, $sources); - - if (0 !== $exitCode) { - throw new \RuntimeException( - sprintf('Impossible to build the archive: `%s` returned %s', $command, $exitCode) - ); - } - } - - /** - * {@inheritdoc} - */ - public function supports($format, $sourceType) - { - return 'git' === $sourceType && in_array($format, array('zip', 'tar', 'tgz')); - } -} \ No newline at end of file diff --git a/src/Composer/Package/Archiver/MercurialArchiver.php b/src/Composer/Package/Archiver/MercurialArchiver.php deleted file mode 100644 index b21750b45..000000000 --- a/src/Composer/Package/Archiver/MercurialArchiver.php +++ /dev/null @@ -1,62 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Package\Archiver; - -use Composer\Util\ProcessExecutor; - -/** - * @author Till Klampaeckel - * @author Matthieu Moquet - */ -class MercurialArchiver implements ArchiverInterface -{ - protected $process; - - public function __construct($process = null) - { - $this->process = $process ?: new ProcessExecutor(); - } - - /** - * {@inheritdoc} - */ - public function archive($sources, $target, $format, $sourceRef = null) - { - if (null === $sourceRef) { - $sourceRef = 'default'; - } - - $command = sprintf( - 'hg archive --rev %s --type %s %s', - escapeshellarg($sourceRef), - $format, - escapeshellarg($target) - ); - - $exitCode = $this->process->execute($command, $output, $sources); - - if (0 !== $exitCode) { - throw new \RuntimeException( - sprintf('Impossible to build the archive: `%s` returned %s', $command, $exitCode) - ); - } - } - - /** - * {@inheritdoc} - */ - public function supports($format, $sourceType) - { - return 'hg' === $sourceType && in_array($format, array('tar', 'tbz2', 'tgz', 'uzip', 'zip')); - } -} \ No newline at end of file diff --git a/tests/Composer/Test/Package/Archiver/GitArchiverTest.php b/tests/Composer/Test/Package/Archiver/GitArchiverTest.php deleted file mode 100644 index 587ed9158..000000000 --- a/tests/Composer/Test/Package/Archiver/GitArchiverTest.php +++ /dev/null @@ -1,95 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Test\Package\Archiver; - -use Composer\Package\Archiver\GitArchiver; - -/** - * @author Till Klampaeckel - * @author Matthieu Moquet - */ -class GitArchiverTest extends ArchiverTest -{ - protected $targetFile; - - public function testZipArchive() - { - // Set up repository - $this->setupGitRepo(); - $package = $this->setupPackage(); - $target = sys_get_temp_dir().'/composer_archiver_test.zip'; - - // Test archive - $archiver = new GitArchiver(); - $archiver->archive($package->getSourceUrl(), $target, 'zip', 'master^1'); - $this->assertFileExists($target); - - unlink($target); - } - - public function testTarArchive() - { - // Set up repository - $this->setupGitRepo(); - $package = $this->setupPackage(); - $target = sys_get_temp_dir().'/composer_archiver_test.tar'; - - // Test archive - $archiver = new GitArchiver(); - $archiver->archive($package->getSourceUrl(), $target, 'tar', 'master^1'); - $this->assertFileExists($target); - - unlink($target); - } - - /** - * Create local git repository to run tests against! - */ - protected function setupGitRepo() - { - $currentWorkDir = getcwd(); - chdir($this->testDir); - - $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()); - } - - $result = file_put_contents('d', 'c'); - if (false === $result) { - chdir($currentWorkDir); - throw new \RuntimeException('Could not save file.'); - } - - $result = $this->process->execute('git add d && git commit -m "commit d" -q'); - if ($result > 0) { - chdir($currentWorkDir); - throw new \RuntimeException('Could not commit: '.$this->process->getErrorOutput()); - } - - chdir($currentWorkDir); - } -} diff --git a/tests/Composer/Test/Package/Archiver/MercurialArchiverTest.php b/tests/Composer/Test/Package/Archiver/MercurialArchiverTest.php deleted file mode 100644 index e3b316a6b..000000000 --- a/tests/Composer/Test/Package/Archiver/MercurialArchiverTest.php +++ /dev/null @@ -1,91 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Test\Package\Archiver; - -use Composer\Package\Archiver\MercurialArchiver; -use Composer\Package\Package; - -/** - * @author Matthieu Moquet - * @author Till Klampaeckel - */ -class MercurialArchiverTest extends ArchiverTest -{ - public function testZipArchive() - { - // Set up repository - $this->setupMercurialRepo(); - $package = $this->setupPackage(); - $target = sys_get_temp_dir().'/composer_archiver_test.zip'; - - // Test archive - $archiver = new MercurialArchiver(); - $archiver->archive($package->getSourceUrl(), $target, 'zip', 'default'); - $this->assertFileExists($target); - - unlink($target); - } - - public function testTarArchive() - { - // Set up repository - $this->setupMercurialRepo(); - $package = $this->setupPackage(); - $target = sys_get_temp_dir().'/composer_archiver_test.tar'; - - // Test archive - $archiver = new MercurialArchiver(); - $archiver->archive($package->getSourceUrl(), $target, 'tar', 'default'); - $this->assertFileExists($target); - - unlink($target); - } - - /** - * Create local mercurial repository to run tests against! - */ - protected function setupMercurialRepo() - { - $currentWorkDir = getcwd(); - chdir($this->testDir); - - $result = $this->process->execute('hg 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('hg add b && hg commit -m "commit b" --config ui.username=test -q'); - if ($result > 0) { - chdir($currentWorkDir); - throw new \RuntimeException('Could not commit: '.$this->process->getErrorOutput()); - } - - chdir($currentWorkDir); - } - - protected function setupPackage() - { - $package = parent::setupPackage(); - $package->setSourceReference('default'); - $package->setSourceType('hg'); - - return $package; - } -}