From c7af918caa5372c2cea8f6ac791a2cf15bb48e84 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 25 Sep 2011 12:39:08 +0200 Subject: [PATCH] Fix git downloader --- src/Composer/Downloader/GitDownloader.php | 34 ++++++++++++++++------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 9b5b036df..cf732bafd 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -19,19 +19,33 @@ use Composer\Package\PackageInterface; */ class GitDownloader implements DownloaderInterface { - protected $clone; - - public function __construct($clone = true) + /** + * {@inheritDoc} + */ + public function download(PackageInterface $package, $path, $url, $checksum = null, $useSource = false) { - $this->clone = $clone; + 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 -'); } - public function download(PackageInterface $package, $path, $url, $checksum = null) + /** + * {@inheritDoc} + */ + public function update(PackageInterface $initial, PackageInterface $target, $path, $useSource = false) { - 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 -'); - } + $cwd = getcwd(); + chdir($path); + system('git pull'); + chdir($cwd); + } + + /** + * {@inheritDoc} + */ + public function remove(PackageInterface $package, $path, $useSource = false) + { + echo 'rm -rf '.$path; // TODO } }