Fixes an issue with stats in paths with whitespace

Splitting on whitespace of the ls-tree output is not enough: when
a path contains a space only the first part is taken as the file
name. This commit changes that behaviour by using another command
to list all the file names.
This commit is contained in:
Camil Staps
2015-11-29 16:41:43 +01:00
parent 3dd25f3b87
commit 3b98f5db0c

View File

@@ -344,9 +344,13 @@ class Repository extends BaseRepository
if (is_numeric($file[3])) {
$data['size'] += $file[3];
}
}
if (($pos = strrpos($file[4], '.')) !== false) {
$extension = substr($file[4], $pos);
$logs = $this->getClient()->run($this, 'ls-tree -l -r --name-only ' . $branch);
$files = explode("\n", $logs);
foreach ($files as $file) {
if (($pos = strrpos($file, '.')) !== false) {
$extension = substr($file, $pos);
if (($pos = strrpos($extension, '/')) === false) {
$data['extensions'][] = $extension;