|
@@ -12,6 +12,7 @@
|
|
|
|
|
|
namespace Composer\Repository\Vcs;
|
|
|
|
|
|
+use Composer\Cache;
|
|
|
use Composer\Config;
|
|
|
use Composer\Json\JsonFile;
|
|
|
use Composer\IO\IOInterface;
|
|
@@ -21,6 +22,7 @@ use Composer\IO\IOInterface;
|
|
|
*/
|
|
|
class HgBitbucketDriver extends VcsDriver
|
|
|
{
|
|
|
+ protected $cache;
|
|
|
protected $owner;
|
|
|
protected $repository;
|
|
|
protected $tags;
|
|
@@ -37,6 +39,7 @@ class HgBitbucketDriver extends VcsDriver
|
|
|
$this->owner = $match[1];
|
|
|
$this->repository = $match[2];
|
|
|
$this->originUrl = 'bitbucket.org';
|
|
|
+ $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -87,6 +90,10 @@ class HgBitbucketDriver extends VcsDriver
|
|
|
*/
|
|
|
public function getComposerInformation($identifier)
|
|
|
{
|
|
|
+ if (preg_match('{[a-f0-9]{40}}i', $identifier) && $res = $this->cache->read($identifier)) {
|
|
|
+ $this->infoCache[$identifier] = JsonFile::parseJson($res);
|
|
|
+ }
|
|
|
+
|
|
|
if (!isset($this->infoCache[$identifier])) {
|
|
|
$resource = $this->getScheme() . '://bitbucket.org/api/1.0/repositories/'.$this->owner.'/'.$this->repository.'/src/'.$identifier.'/composer.json';
|
|
|
$repoData = JsonFile::parseJson($this->getContents($resource), $resource);
|
|
@@ -107,6 +114,11 @@ class HgBitbucketDriver extends VcsDriver
|
|
|
$changeset = JsonFile::parseJson($this->getContents($resource), $resource);
|
|
|
$composer['time'] = $changeset['timestamp'];
|
|
|
}
|
|
|
+
|
|
|
+ if (preg_match('{[a-f0-9]{40}}i', $identifier)) {
|
|
|
+ $this->cache->write($identifier, json_encode($composer));
|
|
|
+ }
|
|
|
+
|
|
|
$this->infoCache[$identifier] = $composer;
|
|
|
}
|
|
|
|