mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-09 21:48:41 +00:00
Filter for loc
This commit is contained in:
parent
8c79ec1a86
commit
24371cf5fd
|
|
@ -16,6 +16,7 @@
|
||||||
namespace phpOMS\Utils\Git;
|
namespace phpOMS\Utils\Git;
|
||||||
|
|
||||||
use phpOMS\System\File\PathException;
|
use phpOMS\System\File\PathException;
|
||||||
|
use phpOMS\Utils\StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository class
|
* Repository class
|
||||||
|
|
@ -387,7 +388,7 @@ class Repository
|
||||||
$path = $this->getDirectoryPath();
|
$path = $this->getDirectoryPath();
|
||||||
$path = str_replace('\\', '/', $path);
|
$path = str_replace('\\', '/', $path);
|
||||||
$path = explode('/', $path);
|
$path = explode('/', $path);
|
||||||
$this->name = $path[count($path) - 2];
|
$this->name = $path[count($path) - ($this->bare ? 1 : 2)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->name;
|
return $this->name;
|
||||||
|
|
@ -669,6 +670,8 @@ class Repository
|
||||||
/**
|
/**
|
||||||
* Get LOC.
|
* Get LOC.
|
||||||
*
|
*
|
||||||
|
* @param array $extensions Extensions whitelist
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
|
|
@ -676,12 +679,16 @@ class Repository
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function getLOC() : int
|
public function getLOC(array $extensions = ['*']) : int
|
||||||
{
|
{
|
||||||
$lines = $this->run('ls-files');
|
$lines = $this->run('ls-files');
|
||||||
$loc = 0;
|
$loc = 0;
|
||||||
|
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
|
if ($extensions[0] !== '*' && !StringUtils::endsWith($line, $extensions)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$fh = fopen($this->getDirectoryPath() . ($this->bare ? '/' : '/../') . $line, 'r');
|
$fh = fopen($this->getDirectoryPath() . ($this->bare ? '/' : '/../') . $line, 'r');
|
||||||
|
|
||||||
while (!feof($fh)) {
|
while (!feof($fh)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user