1
0
Fork 0

Add ChangeReport Interface

Added a ChangeReport Interface to allow also non VCS-Downloaders to check the status of there package
pull/2136/head
Sascha Egerer 2013-07-31 19:17:37 +02:00
parent dc7b46a0cb
commit 667176d1d0
6 changed files with 39 additions and 14 deletions

View File

@ -15,6 +15,7 @@ namespace Composer\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Composer\Downloader\ChangeReportInterface;
use Composer\Downloader\VcsDownloader;
/**
@ -55,10 +56,10 @@ EOT
foreach ($installedRepo->getPackages() as $package) {
$downloader = $dm->getDownloaderForInstalledPackage($package);
if ($downloader instanceof VcsDownloader) {
if ($downloader instanceof ChangeReportInterface) {
$targetDir = $im->getInstallPath($package);
if ($changes = $downloader->getLocalChanges($targetDir)) {
if ($changes = $downloader->getLocalChanges($targetDir, $package)) {
$errors[$targetDir] = $changes;
}
}

View File

@ -0,0 +1,32 @@
<?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;
/**
* ChangeReport interface.
*
* @author Sascha Egerer <sascha.egerer@dkd.de>
*/
interface ChangeReportInterface
{
/**
* Checks for changes to the local copy
*
* @param string $path package directory
* @param PackageInterface $package package instance
* @return string|null changes or null
*/
public function getLocalChanges($path, PackageInterface $package);
}

View File

@ -78,7 +78,7 @@ class GitDownloader extends VcsDownloader
/**
* {@inheritDoc}
*/
public function getLocalChanges($path)
public function getLocalChanges($path, PackageInterface $package)
{
$this->cleanEnv();
$path = $this->normalizePath($path);

View File

@ -59,7 +59,7 @@ class HgDownloader extends VcsDownloader
/**
* {@inheritDoc}
*/
public function getLocalChanges($path)
public function getLocalChanges($path, PackageInterface $package)
{
if (!is_dir($path.'/.hg')) {
return;

View File

@ -52,7 +52,7 @@ class SvnDownloader extends VcsDownloader
/**
* {@inheritDoc}
*/
public function getLocalChanges($path)
public function getLocalChanges($path, PackageInterface $package)
{
if (!is_dir($path.'/.svn')) {
return;

View File

@ -22,7 +22,7 @@ use Composer\Util\Filesystem;
/**
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
abstract class VcsDownloader implements DownloaderInterface
abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterface
{
protected $io;
protected $config;
@ -187,14 +187,6 @@ abstract class VcsDownloader implements DownloaderInterface
*/
abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path);
/**
* Checks for changes to the local copy
*
* @param string $path package directory
* @return string|null changes or null
*/
abstract public function getLocalChanges($path);
/**
* Fetches the commit logs between two commits
*