private function getSubmodules($files, $hash)
{
if ($this->submodules === null) {
foreach ($files as $file) {
if ($file[4] === '.gitmodules') {
$branch = $hash;
$gitsubmodule = $this->getRepository()->getBlob("$branch:\"$file[4]\"")->output();
$this->submodules = parse_ini_string($gitsubmodule, true);
}
}
if ($this->submodules === null && strpos($hash, ':') !== false) {
// Search in root folder
$data = $this->getRepository()->getClient()->run($this->getRepository(), 'ls-tree -lz ' . explode(':', $hash)[0]);
$lines = explode("\0", $data);
$rootFolderFiles = array();
$root = array();
foreach ($lines as $key => $line) {
if (empty($line)) {
unset($lines[$key]);
continue;
}
$rootFolderFiles[] = preg_split("/[\s]+/", $line, 5);
}
$this->submodules = $this->getSubmodules($rootFolderFiles, explode(':', $hash)[0]);
}
}
return $this->submodules;
}
public function decorateItem($filename, $item)
{
$command = 'log -1 --pretty=tformat:"%ar%n%s" ' . explode(':', $this->getHash())[0] . ' -- ' . "\"" . $this->path . $filename . "\"";
//print_r($command);
$fileInfo = explode("\n", $this->getRepository()->getClient()->run($this->getRepository(), $command));
//echo $filename;
//echo "\n";
//print_r($fileInfo);
//echo "\n";
//echo "\n";
$item->setLastModified($fileInfo[0]);
$item->message = $fileInfo[1];
}