diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php index 33c24d4..58ab1f8 100644 --- a/src/IDF/Scm/Git.php +++ b/src/IDF/Scm/Git.php @@ -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; + } + } \ No newline at end of file diff --git a/src/IDF/templates/idf/source/git/tree.html b/src/IDF/templates/idf/source/git/tree.html index 8de19e9..3bcbcd3 100644 --- a/src/IDF/templates/idf/source/git/tree.html +++ b/src/IDF/templates/idf/source/git/tree.html @@ -31,13 +31,17 @@ {aurl 'url', 'IDF_Views_Source::tree', array($project.shortname, $commit, $file.fullpath)} {$file.type} -{$file.file} +{if $file.type != 'extern'} +{$file.file}{else}{$file.file}{/if} {if $file.type == 'blob'} {if isset($file.date) and $file.log != '----'} {$file.date|dateago:"wihtout"} {$file.author|strip_tags|trim}{trans ':'} {issuetext $file.log, $request, true, false} {else}{/if} {$file.size|size}{/if} +{if $file.type == 'extern'} +{$file.extern} +{/if} {/foreach} diff --git a/www/media/idf/img/extern.png b/www/media/idf/img/extern.png new file mode 100644 index 0000000..c8aa43c Binary files /dev/null and b/www/media/idf/img/extern.png differ