You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB
PHTML

<?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>
*/
class GitDownloader implements DownloaderInterface
{
/**
* {@inheritDoc}
*/
public function download(PackageInterface $package, $path, $url, $checksum = null, $useSource = false)
{
system('git clone '.escapeshellarg($url).' -b master '.escapeshellarg($path));
// TODO non-source installs:
// system('git archive --format=tar --prefix='.escapeshellarg($package->getName()).' --remote='.escapeshellarg($url).' master | tar -xf -');
}
/**
* {@inheritDoc}
*/
public function update(PackageInterface $initial, PackageInterface $target, $path, $useSource = false)
{
$cwd = getcwd();
chdir($path);
system('git pull');
chdir($cwd);
}
/**
* {@inheritDoc}
*/
public function remove(PackageInterface $package, $path, $useSource = false)
{
echo 'rm -rf '.$path; // TODO
}
}