From 7895e4a7e0e05b06e0ebfae96fc154c6a2ba75f0 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 6 Dec 2016 22:00:51 +0100 Subject: [PATCH 1/8] Release 1.2.4 --- src/Composer/Composer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php index c874a0796e31..741847121d1b 100644 --- a/src/Composer/Composer.php +++ b/src/Composer/Composer.php @@ -28,9 +28,9 @@ */ class Composer { - const VERSION = '@package_version@'; - const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@'; - const RELEASE_DATE = '@release_date@'; + const VERSION = '1.2.4'; + const BRANCH_ALIAS_VERSION = ''; + const RELEASE_DATE = '2016-12-06 22:00:51'; /** * @var Package\RootPackageInterface From d405ecb3ea0cf6fafcbe1674216fda6411001219 Mon Sep 17 00:00:00 2001 From: Jan Kunzmann Date: Fri, 12 Jun 2015 13:04:12 +0200 Subject: [PATCH 2/8] ClassLoader: Generalized findFileWithExtension to work with multiple extensions --- src/Composer/Autoload/ClassLoader.php | 76 +++++++++++++++++---------- 1 file changed, 48 insertions(+), 28 deletions(-) diff --git a/src/Composer/Autoload/ClassLoader.php b/src/Composer/Autoload/ClassLoader.php index ac67d302a186..f48258ccbe6a 100644 --- a/src/Composer/Autoload/ClassLoader.php +++ b/src/Composer/Autoload/ClassLoader.php @@ -326,13 +326,14 @@ public function findFile($class) return false; } - $file = $this->findFileWithExtension($class, '.php'); - + $exts = ['.php']; // Search for Hack files if we are running on HHVM - if (false === $file && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); + if (defined('HHVM_VERSION')) { + $exts[] = '.hh'; } + $file = $this->findFileWithExtensions($class, $exts); + if (false === $file) { // Remember that this class does not exist. $this->missingClasses[$class] = true; @@ -341,18 +342,22 @@ public function findFile($class) return $file; } - private function findFileWithExtension($class, $ext) + private function findFileWithExtensions($class, array $exts) { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - + $psr4ClassPath = strtr($class, '\\', DIRECTORY_SEPARATOR); $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { - if (0 === strpos($class, $prefix)) { - foreach ($this->prefixDirsPsr4[$prefix] as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { - return $file; + + foreach ($exts as $ext) { + // PSR-4 lookup + $logicalPathPsr4 = $psr4ClassPath . $ext; + + if (isset($this->prefixLengthsPsr4[$first])) { + foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { + if (0 === strpos($class, $prefix)) { + foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + return $file; + } } } } @@ -360,28 +365,35 @@ private function findFileWithExtension($class, $ext) } // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; + if (count($this->fallbackDirsPsr4) > 0) { + foreach ($exts as $ext) { + $logicalPathPsr4 = $psr4ClassPath . $ext; + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } } } // PSR-0 lookup if (false !== $pos = strrpos($class, '\\')) { // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + $psr0ClassPath = substr($psr4ClassPath, 0, $pos + 1) + . strtr(substr($psr4ClassPath, $pos + 1), '_', DIRECTORY_SEPARATOR); } else { // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + $psr0ClassPath = strtr($class, '_', DIRECTORY_SEPARATOR); } if (isset($this->prefixesPsr0[$first])) { foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; + foreach ($exts as $ext) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $psr0ClassPath . $ext)) { + return $file; + } } } } @@ -389,15 +401,23 @@ private function findFileWithExtension($class, $ext) } // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; + if (count($this->fallbackDirsPsr0) > 0) { + foreach ($exts as $ext) { + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $psr0ClassPath . $ext)) { + return $file; + } + } } } // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; + if ($this->useIncludePath) { + foreach ($exts as $ext) { + if ($file = stream_resolve_include_path($psr0ClassPath . $ext)) { + return $file; + } + } } return false; From 3317544f80c69b3ba50f700cee165c62a9154320 Mon Sep 17 00:00:00 2001 From: Jan Kunzmann Date: Fri, 12 Jun 2015 15:08:51 +0200 Subject: [PATCH 3/8] Make include file extensions configurable in package.json --- src/Composer/Autoload/AutoloadGenerator.php | 27 ++++++++++++++-- src/Composer/Autoload/ClassLoader.php | 34 ++++++++++++++++++--- src/Composer/Package/AliasPackage.php | 5 +++ src/Composer/Package/Dumper/ArrayDumper.php | 1 + src/Composer/Package/Loader/ArrayLoader.php | 4 +++ src/Composer/Package/Package.php | 19 ++++++++++++ src/Composer/Package/PackageInterface.php | 7 +++++ 7 files changed, 91 insertions(+), 6 deletions(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index cc71405a4c32..a64dfd5110cf 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -288,7 +288,7 @@ public static function autoload(\$class) } file_put_contents($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath, $staticPhpVersion)); file_put_contents($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix)); - file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion)); + file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $autoloads['extensions'])); $this->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php'); $this->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE'); @@ -383,6 +383,7 @@ public function parseAutoloads(array $packageMap, PackageInterface $mainPackage) $classmap = $this->parseAutoloadsType(array_reverse($sortedPackageMap), 'classmap', $mainPackage); $files = $this->parseAutoloadsType($sortedPackageMap, 'files', $mainPackage); $exclude = $this->parseAutoloadsType($sortedPackageMap, 'exclude-from-classmap', $mainPackage); + $extensions = $this->parseExtensions($packageMap, $mainPackage); krsort($psr0); krsort($psr4); @@ -393,6 +394,7 @@ public function parseAutoloads(array $packageMap, PackageInterface $mainPackage) 'classmap' => $classmap, 'files' => $files, 'exclude-from-classmap' => $exclude, + 'extensions' => $extensions ); } @@ -548,7 +550,7 @@ protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix) AUTOLOAD; } - protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion = 70000) + protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion = 70000, $autoloadExtensions) { $file = <<
setAutoloadExtensions($autoloadExtensions); + +AUTOLOAD_EXTENSION; + } + if ($targetDirLoader) { $file .= <<getName() . ':' . $path); } + protected function parseExtensions(array $packageMap, PackageInterface $mainPackage) { + $extensions = array(); + + foreach ($packageMap as $item) { + list($package, $installPath) = $item; + foreach ($package->getAutoloadExtensions() as $ext) { + $extensions[$ext] = $ext; + } + } + + return array_values($extensions); + } + /** * Sorts packages by dependency weight * diff --git a/src/Composer/Autoload/ClassLoader.php b/src/Composer/Autoload/ClassLoader.php index f48258ccbe6a..20f492a39cec 100644 --- a/src/Composer/Autoload/ClassLoader.php +++ b/src/Composer/Autoload/ClassLoader.php @@ -56,6 +56,8 @@ class ClassLoader private $classMapAuthoritative = false; private $missingClasses = array(); + private $autoloadExtensions = array(); + public function getPrefixes() { if (!empty($this->prefixesPsr0)) { @@ -271,6 +273,26 @@ public function isClassMapAuthoritative() return $this->classMapAuthoritative; } + /** + * Sets autoload extensions + * + * @param $autoloadExtensions + */ + public function setAutoloadExtensions($autoloadExtensions) + { + $this->autoloadExtensions = $autoloadExtensions; + } + + /** + * Returns autoload extensions + * + * @return array + */ + public function getAutoloadExtensions() + { + return $this->autoloadExtensions; + } + /** * Registers this instance as an autoloader. * @@ -326,10 +348,14 @@ public function findFile($class) return false; } - $exts = ['.php']; - // Search for Hack files if we are running on HHVM - if (defined('HHVM_VERSION')) { - $exts[] = '.hh'; + // set autoload extensions with a reasonable default + $exts = $this->autoloadExtensions; + if (count($exts) == 0) { + $exts = ['.php']; + // Search for Hack files if we are running on HHVM + if (defined('HHVM_VERSION')) { + $exts[] = '.hh'; + } } $file = $this->findFileWithExtensions($class, $exts); diff --git a/src/Composer/Package/AliasPackage.php b/src/Composer/Package/AliasPackage.php index 09ed4fb9b5f8..c87bb58f8a7c 100644 --- a/src/Composer/Package/AliasPackage.php +++ b/src/Composer/Package/AliasPackage.php @@ -327,6 +327,11 @@ public function getDevAutoload() return $this->aliasOf->getDevAutoload(); } + public function getAutoloadExtensions() + { + return $this->aliasOf->getAutoloadExtensions(); + } + public function getIncludePaths() { return $this->aliasOf->getIncludePaths(); diff --git a/src/Composer/Package/Dumper/ArrayDumper.php b/src/Composer/Package/Dumper/ArrayDumper.php index 714c5183b9b1..cce77869eb2f 100644 --- a/src/Composer/Package/Dumper/ArrayDumper.php +++ b/src/Composer/Package/Dumper/ArrayDumper.php @@ -32,6 +32,7 @@ public function dump(PackageInterface $package) 'installationSource' => 'installation-source', 'autoload', 'devAutoload' => 'autoload-dev', + 'autoloadExtensions' => 'autoload-extensions', 'notificationUrl' => 'notification-url', 'includePaths' => 'include-path', ); diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index f7e60708520a..e50585938de5 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -144,6 +144,10 @@ public function load(array $config, $class = 'Composer\Package\CompletePackage') $package->setDevAutoload($config['autoload-dev']); } + if (isset($config['autoload-extensions'])) { + $package->setAutoloadExtensions($config['autoload-extensions']); + } + if (isset($config['include-path'])) { $package->setIncludePaths($config['include-path']); } diff --git a/src/Composer/Package/Package.php b/src/Composer/Package/Package.php index 6c7b426e75b5..889597ee49b4 100644 --- a/src/Composer/Package/Package.php +++ b/src/Composer/Package/Package.php @@ -56,6 +56,7 @@ class Package extends BasePackage protected $suggests = array(); protected $autoload = array(); protected $devAutoload = array(); + protected $autoloadExtensions = array(); protected $includePaths = array(); protected $archiveExcludes = array(); @@ -515,6 +516,24 @@ public function getDevAutoload() return $this->devAutoload; } + /** + * Set the autoload extensions + * + * @param array $extensions + */ + public function setAutoloadExtensions(array $extensions) + { + $this->autoloadExtensions = $extensions; + } + + /** + * {@inheritDoc} + */ + public function getAutoloadExtensions() + { + return $this->autoloadExtensions; + } + /** * Sets the list of paths added to PHP's include path. * diff --git a/src/Composer/Package/PackageInterface.php b/src/Composer/Package/PackageInterface.php index 73d2ade41543..518a24e52eed 100644 --- a/src/Composer/Package/PackageInterface.php +++ b/src/Composer/Package/PackageInterface.php @@ -288,6 +288,13 @@ public function getAutoload(); */ public function getDevAutoload(); + /** + * Returns an array of autoloading extensions + * + * @return array + */ + public function getAutoloadExtensions(); + /** * Returns a list of directories which should get added to PHP's * include path. From ddb26ab22f0891f01d66f6b79f92bd36534e49db Mon Sep 17 00:00:00 2001 From: Jan Kunzmann Date: Mon, 15 Jun 2015 15:41:25 +0200 Subject: [PATCH 4/8] Improved composer console output if a repository is about to be deleted --- src/Composer/Downloader/DownloadManager.php | 1 + src/Composer/Installer/LibraryInstaller.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Composer/Downloader/DownloadManager.php b/src/Composer/Downloader/DownloadManager.php index d18bb1cedcf2..a5edf3170f54 100644 --- a/src/Composer/Downloader/DownloadManager.php +++ b/src/Composer/Downloader/DownloadManager.php @@ -256,6 +256,7 @@ public function update(PackageInterface $initial, PackageInterface $target, $tar // upgrading from a dist stable package to a dev package, force source reinstall if ($target->isDev() && 'dist' === $installationSource) { + $this->io->writeError(" Installation source changed from stable to dev, wiping $targetDir"); $downloader->remove($initial, $targetDir); $this->download($target, $targetDir); diff --git a/src/Composer/Installer/LibraryInstaller.php b/src/Composer/Installer/LibraryInstaller.php index 4b1a955468ec..573fecc927b8 100644 --- a/src/Composer/Installer/LibraryInstaller.php +++ b/src/Composer/Installer/LibraryInstaller.php @@ -196,6 +196,7 @@ protected function updateCode(PackageInterface $initial, PackageInterface $targe if (substr($initialDownloadPath, 0, strlen($targetDownloadPath)) === $targetDownloadPath || substr($targetDownloadPath, 0, strlen($initialDownloadPath)) === $initialDownloadPath ) { + $this->io->writeError(" Installation download path changed, wiping library directory"); $this->removeCode($initial); $this->installCode($target); From 1785d73c7cd8f0041970cbb191f18cae616084a0 Mon Sep 17 00:00:00 2001 From: Jan Kunzmann Date: Mon, 15 Jun 2015 18:31:36 +0200 Subject: [PATCH 5/8] Make self-update unusable --- src/Composer/Command/SelfUpdateCommand.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index c0834e2c88f9..8c58c7de6a4a 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -41,7 +41,7 @@ protected function configure() $this ->setName('self-update') ->setAliases(array('selfupdate')) - ->setDescription('Updates composer.phar to the latest version.') + ->setDescription('Updates composer.phar to the latest version. Do not use in erasys environment!') ->setDefinition(array( new InputOption('rollback', 'r', InputOption::VALUE_NONE, 'Revert to an older installation of composer'), new InputOption('clean-backups', null, InputOption::VALUE_NONE, 'Delete old backups during an update. This makes the current version of composer the only backup available after the update'), @@ -65,6 +65,9 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { + $this->getIO()->writeError('Composer should not be updated with this command in erasys environment.'); + return; + $config = Factory::createConfig(); if ($config->get('disable-tls') === true) { From 96d6af36fa495955ae0505d97c6642d2ac3fef8a Mon Sep 17 00:00:00 2001 From: Konrad Gibaszewski Date: Fri, 12 Jun 2015 15:46:46 +0200 Subject: [PATCH 6/8] Adds GitArchiver, Bzip2Downloader, fixes TarDownloader Details: Bzip2Downloader - Intermediate file is always .tar, removes intermediate tar file after download completion Bzip2Downloader - Supports tar.z2 files (requires PHP 5.5.24+) TarDownloader - Adds exception handling GitArchiver - refactored to use only tar and tar.bz2 GitArchiver - while trying to discover a tag consider both annotated and unannotated tags --- src/Composer/Downloader/Bzip2Downloader.php | 51 +++++++++++++++ src/Composer/Downloader/TarDownloader.php | 38 ++++++++---- src/Composer/Factory.php | 2 + .../Package/Archiver/ArchiveManager.php | 2 +- src/Composer/Package/Archiver/GitArchiver.php | 62 +++++++++++++++++++ 5 files changed, 143 insertions(+), 12 deletions(-) create mode 100644 src/Composer/Downloader/Bzip2Downloader.php create mode 100644 src/Composer/Package/Archiver/GitArchiver.php diff --git a/src/Composer/Downloader/Bzip2Downloader.php b/src/Composer/Downloader/Bzip2Downloader.php new file mode 100644 index 000000000000..d240c6da80e5 --- /dev/null +++ b/src/Composer/Downloader/Bzip2Downloader.php @@ -0,0 +1,51 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Downloader; + +/** + * Downloader for tar.bz2 files + * + * @author Konrad Gibaszewski + */ +class Bzip2Downloader extends ArchiveDownloader { + + /** + * {@inheritDoc} + */ + protected function extract($file, $path) { + + try { + // decompress from bz2 to tar + $archive = new \PharData($file); + $archive->decompress(); + + // Unpack from tar + $file = substr($file, 0, -4) . '.tar'; + $archive = new \PharData($file); + $archive->extractTo($path, null, true); + + // Remove intermediate tar file + unlink($file); + + } catch (\UnexpectedValueException $e) { + $message = sprintf("Could not extract archive '%s': %s", + $file, + $e->getMessage() + ); + + throw new \RuntimeException($message, $e->getCode(), $e); + } + + } + +} diff --git a/src/Composer/Downloader/TarDownloader.php b/src/Composer/Downloader/TarDownloader.php index 34c43da5fdc6..c3f46e44ab63 100644 --- a/src/Composer/Downloader/TarDownloader.php +++ b/src/Composer/Downloader/TarDownloader.php @@ -13,19 +13,35 @@ namespace Composer\Downloader; /** - * Downloader for tar files: tar, tar.gz or tar.bz2 + * Class TarDownloader + * + * Downloader for uncompressed tar files * * @author Kirill chEbba Chebunin + * @author Konrad Gibaszewski + * + * @package Composer\Downloader */ -class TarDownloader extends ArchiveDownloader -{ - /** - * {@inheritDoc} - */ - protected function extract($file, $path) - { - // Can throw an UnexpectedValueException - $archive = new \PharData($file); - $archive->extractTo($path, null, true); +class TarDownloader extends ArchiveDownloader { + + /** + * {@inheritDoc} + */ + protected function extract($file, $path) { + + try { + // Unpack from tar + $archive = new \PharData($file); + $archive->extractTo($path, null, true); + + } catch (\UnexpectedValueException $e) { + $message = sprintf("Could not unpack from tar archive '%s': %s", + $file, + $e->getMessage() + ); + + throw new \RuntimeException($message, $e->getCode(), $e); } + } + } diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index 4bfae989ab17..778cc89dfc83 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -465,6 +465,7 @@ public function createDownloadManager(IOInterface $io, Config $config, EventDisp $dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $eventDispatcher, $cache, $executor, $rfs)); $dm->setDownloader('rar', new Downloader\RarDownloader($io, $config, $eventDispatcher, $cache, $executor, $rfs)); $dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $eventDispatcher, $cache, $rfs)); + $dm->setDownloader('tar.bz2', new Downloader\Bzip2Downloader($io, $config, $eventDispatcher, $cache)); $dm->setDownloader('gzip', new Downloader\GzipDownloader($io, $config, $eventDispatcher, $cache, $executor, $rfs)); $dm->setDownloader('xz', new Downloader\XzDownloader($io, $config, $eventDispatcher, $cache, $executor, $rfs)); $dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $eventDispatcher, $cache, $rfs)); @@ -490,6 +491,7 @@ public function createArchiveManager(Config $config, Downloader\DownloadManager $am = new Archiver\ArchiveManager($dm); $am->addArchiver(new Archiver\ZipArchiver); $am->addArchiver(new Archiver\PharArchiver); + $am->addArchiver(new Archiver\GitArchiver); return $am; } diff --git a/src/Composer/Package/Archiver/ArchiveManager.php b/src/Composer/Package/Archiver/ArchiveManager.php index 52fe7bed3a87..a1b400479bfc 100644 --- a/src/Composer/Package/Archiver/ArchiveManager.php +++ b/src/Composer/Package/Archiver/ArchiveManager.php @@ -26,7 +26,7 @@ class ArchiveManager { protected $downloadManager; - protected $archivers = array(); + protected $archivers = []; /** * @var bool diff --git a/src/Composer/Package/Archiver/GitArchiver.php b/src/Composer/Package/Archiver/GitArchiver.php new file mode 100644 index 000000000000..4de3a965b8e3 --- /dev/null +++ b/src/Composer/Package/Archiver/GitArchiver.php @@ -0,0 +1,62 @@ + + * 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\Git as GitUtil; + +/** + * @author Till Klampaeckel + * @author Nils Adermann + * @author Matthieu Moquet + * @author Konrad Gibaszewski + */ +class GitArchiver implements ArchiverInterface { + + protected static $formats = [ + 'tar' => \Phar::TAR, + 'tar.gz' => \Phar::GZ, + 'tar.bz2' => \Phar::BZ2, + ]; + + /** + * {@inheritdoc} + */ + public function archive($sources, $target, $format, array $excludes = []) { + + $sources = realpath($sources); + + GitUtil::cleanEnv(); + + try { + $tag = shell_exec("cd $sources && git describe --tags"); + shell_exec("cd $sources && git archive -o $target $tag"); + return $target; + } catch (\UnexpectedValueException $e) { + $message = sprintf("Could not create archive '%s' from '%s': %s", + $target, + $sources, + $e->getMessage() + ); + + throw new \RuntimeException($message, $e->getCode(), $e); + } + } + + /** + * {@inheritdoc} + */ + public function supports($format, $sourceType) { + return isset(static::$formats[$format]); + } + +} From 3d6a26f2ce762a0997ba30f89ec2e55e279a7d10 Mon Sep 17 00:00:00 2001 From: Lukas Koell Date: Thu, 18 Jun 2015 13:09:22 +0200 Subject: [PATCH 7/8] Bzip2Downloader use command line tar instead of \PharData --- src/Composer/Downloader/Bzip2Downloader.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/Composer/Downloader/Bzip2Downloader.php b/src/Composer/Downloader/Bzip2Downloader.php index d240c6da80e5..c9b98304e0aa 100644 --- a/src/Composer/Downloader/Bzip2Downloader.php +++ b/src/Composer/Downloader/Bzip2Downloader.php @@ -23,20 +23,8 @@ class Bzip2Downloader extends ArchiveDownloader { * {@inheritDoc} */ protected function extract($file, $path) { - try { - // decompress from bz2 to tar - $archive = new \PharData($file); - $archive->decompress(); - - // Unpack from tar - $file = substr($file, 0, -4) . '.tar'; - $archive = new \PharData($file); - $archive->extractTo($path, null, true); - - // Remove intermediate tar file - unlink($file); - + exec('tar xfj ' . ' ' . $file . ' -C ' . $path); } catch (\UnexpectedValueException $e) { $message = sprintf("Could not extract archive '%s': %s", $file, From 7e1235c1caf90e05f314208949b331407459b5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esbjo=CC=88rn=20Eriksson?= Date: Mon, 12 Dec 2016 12:46:31 +0100 Subject: [PATCH 8/8] Update version --- src/Composer/Composer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php index 741847121d1b..d06d75ca67e7 100644 --- a/src/Composer/Composer.php +++ b/src/Composer/Composer.php @@ -28,8 +28,8 @@ */ class Composer { - const VERSION = '1.2.4'; - const BRANCH_ALIAS_VERSION = ''; + const VERSION = '1.2.4-erasys-1'; + const BRANCH_ALIAS_VERSION = 'erasys'; const RELEASE_DATE = '2016-12-06 22:00:51'; /**