Fixed issues 137 and 138, support of the git submodules.

dev
Loic d'Anterroches 2009-02-27 13:38:22 +01:00
parent e40485c56f
commit cfafdbfde4
3 changed files with 38 additions and 1 deletions

View File

@ -165,6 +165,10 @@ class IDF_Scm_Git
$file->author = 'Unknown';
}
$file->fullpath = ($folder) ? $folder.'/'.$file->file : $file->file;
if ($file->type == 'commit') {
// We have a submodule
$file = $this->getSubmodule($file, $commit);
}
$res[] = $file;
}
return $res;
@ -418,4 +422,33 @@ class IDF_Scm_Git
escapeshellarg($commit));
}
/*
* =====================================================
* Specific Git Commands
* =====================================================
*/
/**
* Get submodule details.
*
* Given a "commit" file in the tree, find the submodule details.
*
* @param stdClass File description of the module
* @param string Current commit
* @return stdClass File description
*/
public function getSubmodule($file, $commit)
{
$file->type = 'extern';
$info = $this->getFileInfo('.gitmodules', $commit);
if ($info == false) {
return $file;
}
$gitmodules = $this->getBlob($info);
if (preg_match('#\[submodule\s+\"'.$file->fullpath.'\"\]\s+path\s=\s(\S+)\s+url\s=\s(\S+)#mi', $gitmodules, $matches)) {
$file->extern = $matches[2];
}
return $file;
}
}

View File

@ -31,13 +31,17 @@
{aurl 'url', 'IDF_Views_Source::tree', array($project.shortname, $commit, $file.fullpath)}
<tr>
<td class="fileicon"><img src="{media '/idf/img/'~$file.type~'.png'}" alt="{$file.type}" /></td>
<td{if $file.type != 'blob'} colspan="4"{/if}><a href="{$url}">{$file.file}</a></td>
{if $file.type != 'extern'}
<td{if $file.type == 'tree'} colspan="4"{/if}><a href="{$url}">{$file.file}</a></td>{else}<td><a href="#" title="{$file.hash}">{$file.file}</a></td>{/if}
{if $file.type == 'blob'}
{if isset($file.date) and $file.log != '----'}
<td><span class="smaller">{$file.date|dateago:"wihtout"}</span></td>
<td><span class="smaller">{$file.author|strip_tags|trim}{trans ':'} {issuetext $file.log, $request, true, false}</span></td>
{else}<td colspan="2"></td>{/if}
<td>{$file.size|size}</td>{/if}
{if $file.type == 'extern'}
<td colspan="3">{$file.extern}</td>
{/if}
</tr>
{/foreach}
</tbody>

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B