Add isFresh to InstalledRepositoryInterface and make sure local repo is always an InstalledRepositoryInterface
parent
8a1e9744a0
commit
6529fabb24
|
@ -28,7 +28,7 @@ use Composer\Util\Filesystem;
|
|||
*/
|
||||
class FilesystemRepository extends WritableArrayRepository
|
||||
{
|
||||
private $file;
|
||||
protected $file;
|
||||
private $dumpVersions;
|
||||
private $rootPackage;
|
||||
|
||||
|
|
|
@ -25,4 +25,14 @@ class InstalledArrayRepository extends WritableArrayRepository implements Instal
|
|||
{
|
||||
return 'installed '.parent::getRepoName();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isFresh()
|
||||
{
|
||||
// this is not a completely correct implementation but there is no way to
|
||||
// distinguish an empty repo and a newly created one given this is all in-memory
|
||||
return $this->count() === 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,4 +23,12 @@ class InstalledFilesystemRepository extends FilesystemRepository implements Inst
|
|||
{
|
||||
return 'installed '.parent::getRepoName();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isFresh()
|
||||
{
|
||||
return !$this->file->exists();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,4 +21,8 @@ namespace Composer\Repository;
|
|||
*/
|
||||
interface InstalledRepositoryInterface extends WritableRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @return bool true if packages were never installed in this repository
|
||||
*/
|
||||
public function isFresh();
|
||||
}
|
||||
|
|
|
@ -163,9 +163,9 @@ class RepositoryManager
|
|||
/**
|
||||
* Sets local repository for the project.
|
||||
*
|
||||
* @param WritableRepositoryInterface $repository repository instance
|
||||
* @param InstalledRepositoryInterface $repository repository instance
|
||||
*/
|
||||
public function setLocalRepository(WritableRepositoryInterface $repository)
|
||||
public function setLocalRepository(InstalledRepositoryInterface $repository)
|
||||
{
|
||||
$this->localRepository = $repository;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ class RepositoryManager
|
|||
/**
|
||||
* Returns local repository for the project.
|
||||
*
|
||||
* @return WritableRepositoryInterface
|
||||
* @return InstalledRepositoryInterface
|
||||
*/
|
||||
public function getLocalRepository()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue