* Jordi Boggiano * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Composer\Downloader; use Composer\Package\PackageInterface; /** * @author Jordi Boggiano */ class GitDownloader { protected $clone; public function __construct($clone = true) { $this->clone = $clone; } public function download(PackageInterface $package, $path, $url, $checksum = null) { if (!is_dir($path)) { if (file_exists($path)) { throw new \UnexpectedValueException($path.' exists and is not a directory.'); } if (!mkdir($path, 0777, true)) { throw new \UnexpectedValueException($path.' does not exist and could not be created.'); } } if ($this->clone) { system('git clone '.escapeshellarg($url).' -b master '.escapeshellarg($path.'/'.$package->getName())); } else { system('git archive --format=tar --prefix='.escapeshellarg($package->getName()).' --remote='.escapeshellarg($url).' master | tar -xf -'); } } }