Implement NullCommit

This commit is contained in:
Dennis Eichhorn 2018-06-03 10:33:27 +02:00
parent 905dbe3b48
commit a4b6411fcd
2 changed files with 32 additions and 8 deletions

27
Utils/Git/NullCommit.php Normal file
View File

@ -0,0 +1,27 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package phpOMS\Utils\Git
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace phpOMS\Utils\Git;
/**
* Gray encoding class
*
* @package phpOMS\Utils\Git
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
class NullCommit extends Commit
{
}

View File

@ -864,8 +864,7 @@ class Repository
$count = count($lines);
if (empty($lines)) {
// todo: return null commit
return new Commit();
return new NullCommit();
}
\preg_match('/[0-9ABCDEFabcdef]{40}/', $lines[0], $matches);
@ -878,10 +877,9 @@ class Repository
return new Commit();
}
// todo: validate if array values are all initialized
$author = \explode(':', $lines[1]);
$author = \explode('<', trim($author[1]));
$date = substr($lines[2], 6);
$author = \explode(':', $lines[1] ?? '');
$author = \explode('<', trim($author[1] ?? ''));
$date = substr($lines[2] ?? '', 6);
$commit = new Commit($matches[0]);
$commit->setAuthor(new Author(trim($author[0] ?? ''), rtrim($author[1] ?? '', '>')));
@ -914,8 +912,7 @@ class Repository
$lines = $this->run('log -n ' . $limit);
if (empty($lines)) {
// todo: return nullcommit
return new Commit();
return new NullCommit();
}
\preg_match('/[0-9ABCDEFabcdef]{40}/', $lines[0], $matches);