Skip to content

Commit

Permalink
Fix the bug for counter variable type on PR #183
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Dec 10, 2020
1 parent d1fe467 commit 86781ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/Gitonomy/Git/Parser/DiffParser.php
Expand Up @@ -97,10 +97,10 @@ protected function doParse()
// 5. Diff
while ($this->expects('@@ ')) {
$vars = $this->consumeRegexp('/-(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))?/');
$rangeOldStart = $vars[1];
$rangeOldCount = $vars[2];
$rangeNewStart = $vars[3];
$rangeNewCount = isset($vars[4]) ? $vars[4] : $vars[2]; // @todo Ici, t'as pris un gros raccourci mon loulou
$rangeOldStart = (int) $vars[1];
$rangeOldCount = (int) $vars[2];
$rangeNewStart = (int) $vars[3];
$rangeNewCount = isset($vars[4]) ? (int) $vars[4] : (int) $vars[2]; // @todo Ici, t'as pris un gros raccourci mon loulou
$this->consume(' @@');
$this->consumeTo("\n");
$this->consumeNewLine();
Expand Down
8 changes: 4 additions & 4 deletions tests/Gitonomy/Git/Tests/DiffTest.php
Expand Up @@ -134,10 +134,10 @@ public function testDiffRangeParse($repository)

$changes = $files[0]->getChanges();

$this->assertEquals(0, $changes[0]->getRangeOldStart());
$this->assertEquals(0, $changes[0]->getRangeOldCount());
$this->assertSame(0, $changes[0]->getRangeOldStart());
$this->assertSame(0, $changes[0]->getRangeOldCount());

$this->assertEquals(1, $changes[0]->getRangeNewStart());
$this->assertEquals(0, $changes[0]->getRangeNewCount());
$this->assertSame(1, $changes[0]->getRangeNewStart());
$this->assertSame(0, $changes[0]->getRangeNewCount());
}
}

0 comments on commit 86781ea

Please sign in to comment.