diff --git a/Utils/Git/Commit.php b/Utils/Git/Commit.php index e31bcaf48..7bd2bce65 100644 --- a/Utils/Git/Commit.php +++ b/Utils/Git/Commit.php @@ -338,10 +338,10 @@ class Commit * * @since 1.0.0 */ - private function addChange(string $path, int $line, string $old, string $new) : void + public function addChanges(string $path, int $line, string $old, string $new) : void { if (!isset($this->files[$path])) { - throw new \Exception(); + $this->files[$path] = []; } if (!isset($this->files[$path][$line])) { diff --git a/tests/Utils/Git/CommitTest.php b/tests/Utils/Git/CommitTest.php index 8f975b6be..f90b7728d 100644 --- a/tests/Utils/Git/CommitTest.php +++ b/tests/Utils/Git/CommitTest.php @@ -51,6 +51,27 @@ class CommitTest extends \PHPUnit\Framework\TestCase self::assertEquals([ '/some/file/path2' => [] ], $commit->getFiles()); + + $commit->addChanges(__DIR__ . '/CommitTest.php', 1, ' [ + 1 => [ + 'old' => ' 'test' + ] + ] + ], $commit->getFiles()); + } + + /** + * @expectedException \Exception + */ + public function testDuplicateLineChange() + { + $commit = new Commit(); + $commit->addChanges(__DIR__ . '/CommitTest.php', 1, 'addChanges(__DIR__ . '/CommitTest.php', 1, '