2011-04-17 22:14:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of Composer.
|
|
|
|
*
|
|
|
|
* (c) Nils Adermann <naderman@naderman.de>
|
|
|
|
* Jordi Boggiano <j.boggiano@seld.be>
|
|
|
|
*
|
|
|
|
* 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 <j.boggiano@seld.be>
|
|
|
|
*/
|
2011-09-15 19:58:00 +00:00
|
|
|
class GitDownloader implements DownloaderInterface
|
2011-04-17 22:14:44 +00:00
|
|
|
{
|
|
|
|
protected $clone;
|
|
|
|
|
|
|
|
public function __construct($clone = true)
|
|
|
|
{
|
|
|
|
$this->clone = $clone;
|
|
|
|
}
|
|
|
|
|
2011-07-06 19:06:52 +00:00
|
|
|
public function download(PackageInterface $package, $path, $url, $checksum = null)
|
2011-04-17 22:14:44 +00:00
|
|
|
{
|
|
|
|
if ($this->clone) {
|
2011-07-06 19:06:52 +00:00
|
|
|
system('git clone '.escapeshellarg($url).' -b master '.escapeshellarg($path.'/'.$package->getName()));
|
2011-04-17 22:14:44 +00:00
|
|
|
} else {
|
2011-07-06 19:06:52 +00:00
|
|
|
system('git archive --format=tar --prefix='.escapeshellarg($package->getName()).' --remote='.escapeshellarg($url).' master | tar -xf -');
|
2011-04-17 22:14:44 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-17 13:12:45 +00:00
|
|
|
}
|