|
@@ -17,12 +17,14 @@ use Composer\Util\ProcessExecutor;
|
|
|
use Composer\Util\Filesystem;
|
|
|
use Composer\Util\Git as GitUtil;
|
|
|
use Composer\IO\IOInterface;
|
|
|
+use Composer\Cache;
|
|
|
|
|
|
/**
|
|
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
|
|
*/
|
|
|
class GitDriver extends VcsDriver
|
|
|
{
|
|
|
+ protected $cache;
|
|
|
protected $tags;
|
|
|
protected $branches;
|
|
|
protected $rootIdentifier;
|
|
@@ -77,6 +79,8 @@ class GitDriver extends VcsDriver
|
|
|
|
|
|
$this->getTags();
|
|
|
$this->getBranches();
|
|
|
+
|
|
|
+ $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $this->url));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -132,6 +136,10 @@ class GitDriver 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 = sprintf('%s:composer.json', escapeshellarg($identifier));
|
|
|
$this->process->execute(sprintf('git show %s', $resource), $composer, $this->repoDir);
|
|
@@ -147,6 +155,11 @@ class GitDriver extends VcsDriver
|
|
|
$date = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
|
|
|
$composer['time'] = $date->format('Y-m-d H:i:s');
|
|
|
}
|
|
|
+
|
|
|
+ if (preg_match('{[a-f0-9]{40}}i', $identifier)) {
|
|
|
+ $this->cache->write($identifier, json_encode($composer));
|
|
|
+ }
|
|
|
+
|
|
|
$this->infoCache[$identifier] = $composer;
|
|
|
}
|
|
|
|