From 7f1ef7dc403ad7c8bd7389b44886b77772c0662b Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sun, 15 Nov 2015 22:39:13 -0600 Subject: [PATCH] Issue 112: Missing git information for some files --- indefero/src/IDF/Scm/Git.php | 33 ++++++++++++++++++++----------- indefero/src/IDF/Views/Source.php | 8 -------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/indefero/src/IDF/Scm/Git.php b/indefero/src/IDF/Scm/Git.php index be98d89..454c254 100644 --- a/indefero/src/IDF/Scm/Git.php +++ b/indefero/src/IDF/Scm/Git.php @@ -724,7 +724,7 @@ class IDF_Scm_Git extends IDF_Scm $details = array(); for ($i=0;$i<$n;$i++) { if ($tree[$i]->type == 'blob') { - $details[$tree[$i]->hash] = $i; + $details[sha1($tree[$i]->hash . $tree[$i]->fullpath)] = $i; } } if (!count($details)) { @@ -778,17 +778,26 @@ class IDF_Scm_Git extends IDF_Scm sprintf($cmd, $skip), $rawlog); while (count($rawlog) and count($blobs)) { $rawlog = implode("\n", array_reverse($rawlog)); - foreach ($blobs as $blob => $idx) { - if (preg_match('/^\:\d{6} \d{6} [0-9a-f]{40} ' - .$blob.' .*^([0-9a-f]{40})/msU', - $rawlog, $matches)) { - $fc = $this->getCommit($matches[1]); - $res[$blob] = (object) array('hash' => $blob, - 'date' => $fc->date, - 'title' => $fc->title, - 'author' => $fc->author); - unset($blobs[$blob]); - } + $newRawLog = substr($rawlog, 0, strrpos(rtrim($rawlog), "\n")); + $rawLogArr = explode("\n", $rawlog); + $lastLine = $rawLogArr[count($rawLogArr) - 1]; + $commit = explode(" ", $lastLine)[0]; + $fc = $this->getCommit($commit); + + + foreach(explode("\n", $newRawLog) as $line) { + $sides = explode("\t", $line); + $leftSide = trim($sides[0]); + $rightSide = trim($sides[1]); + $leftSideSplit = explode(" ", $leftSide); + $newHash = sha1($leftSideSplit[3] . $rightSide); + $res[$newHash] = (object) [ + "hash" => $newHash, + 'date' => $fc->date, + 'title' => $fc->title, + 'author' => $fc->author + ]; + unset($blobs[$newHash]); } $rawlog = array(); $skip += 5000; diff --git a/indefero/src/IDF/Views/Source.php b/indefero/src/IDF/Views/Source.php index bb64927..fc7c088 100644 --- a/indefero/src/IDF/Views/Source.php +++ b/indefero/src/IDF/Views/Source.php @@ -161,15 +161,7 @@ class IDF_Views_Source $in_branches = $scm->inBranches($commit, ''); $tags = $scm->getTags(); $in_tags = $scm->inTags($commit, ''); - // Cache may work only if we filter for "default" or "tip" commits - //$cache = Pluf_Cache::factory(); $res = new Pluf_Template_ContextVars($scm->getTree($commit)); - $key = sprintf('Project:%s::IDF_Views_Source::treeBase:%s::', - $request->project->id, $commit); - /*if (null === ($res=$cache->get($key))) { - - $cache->set($key, $res); - }*/ $scmConf = $request->conf->getVal('scm', 'git'); $props = $scm->getProperties($commit); $res->uasort(array('IDF_Views_Source', 'treeSort'));